/// <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_Child_Page 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> 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> 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> 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> Refresh the aggregation code list by pulling the data back from the database </summary> /// <returns> TRUE if successful, otherwise FALSE </returns> public static bool RefreshCodes() { try { lock (codesLock) { if (codes == null) { codes = new Aggregation_Code_Manager(); } Engine_Database.Populate_Code_Manager(codes, null); } return(true); } catch (Exception ee) { return(ee.Message.Length > 0); } }
/// <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 MySobek_HtmlSubwriter class </summary> /// <param name="Results_Statistics"> Information about the entire set of results for a browse of a user's bookshelf folder </param> /// <param name="Paged_Results"> Single page of results for a browse of a user's bookshelf folder, within the entire set </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="All_Items_Lookup"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item">Current item to edit, if the user is requesting to edit an item</param> /// <param name="Aggregation_Aliases"> List of all existing aliases for existing aggregations </param> /// <param name="Web_Skin_Collection"> Collection of all the web skins </param> /// <param name="Current_User"> Currently logged on user </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="IP_Restrictions"> List of all IP Restriction ranges in use by this digital library </param> /// <param name="URL_Portals"> List of all web portals into this system </param> /// <param name="Stats_Date_Range"> Object contains the start and end dates for the statistical data in the database </param> /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public MySobek_HtmlSubwriter(Search_Results_Statistics Results_Statistics, List <iSearch_Title_Result> Paged_Results, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object All_Items_Lookup, Item_Aggregation Hierarchy_Object, SobekCM_Skin_Object HTML_Skin, Language_Support_Info Translator, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Dictionary <string, string> Aggregation_Aliases, SobekCM_Skin_Collection Web_Skin_Collection, User_Object Current_User, IP_Restriction_Ranges IP_Restrictions, Dictionary <string, Wordmark_Icon> Icon_Table, Portal_List URL_Portals, Statistics_Dates Stats_Date_Range, List <Thematic_Heading> Thematic_Headings, Custom_Tracer Tracer) { Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Saving values and geting user object back from the session"); resultsStatistics = Results_Statistics; pagedResults = Paged_Results; codeManager = Code_Manager; itemList = All_Items_Lookup; htmlSkin = HTML_Skin; translator = Translator; currentCollection = Hierarchy_Object; currentItem = Current_Item; user = Current_User; ipRestrictions = IP_Restrictions; iconTable = Icon_Table; statsDates = Stats_Date_Range; if (Current_Mode.My_Sobek_Type == My_Sobek_Type_Enum.Log_Out) { Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Performing logout"); HttpContext.Current.Session["user"] = null; HttpContext.Current.Response.Redirect("?"); } if ((Current_Mode.My_Sobek_Type != My_Sobek_Type_Enum.Logon) && (user != null) && (user.Is_Temporary_Password)) { Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.New_Password; } if (Current_Mode.Logon_Required) { Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Logon; } Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Building the my sobek viewer object"); switch (Current_Mode.My_Sobek_Type) { case My_Sobek_Type_Enum.Home: mySobekViewer = new Home_MySobekViewer(user, Tracer); break; case My_Sobek_Type_Enum.New_Item: mySobekViewer = new New_Group_And_Item_MySobekViewer(user, Current_Mode, itemList, codeManager, iconTable, htmlSkin, translator, Tracer); break; case My_Sobek_Type_Enum.Folder_Management: mySobekViewer = new Folder_Mgmt_MySobekViewer(user, resultsStatistics, pagedResults, codeManager, itemList, currentCollection, htmlSkin, translator, Current_Mode, Tracer); break; case My_Sobek_Type_Enum.Saved_Searches: mySobekViewer = new Saved_Searches_MySobekViewer(user, translator, Current_Mode, Tracer); break; case My_Sobek_Type_Enum.Preferences: mySobekViewer = new Preferences_MySobekViewer(user, Tracer); break; case My_Sobek_Type_Enum.Logon: mySobekViewer = new Logon_MySobekViewer(Current_Mode, Tracer); break; case My_Sobek_Type_Enum.New_Password: mySobekViewer = new NewPassword_MySobekViewer(user, Tracer); break; case My_Sobek_Type_Enum.Delete_Item: mySobekViewer = new Delete_Item_MySobekViewer(user, Current_Mode, All_Items_Lookup, Tracer); break; case My_Sobek_Type_Enum.Edit_Item_Behaviors: mySobekViewer = new Edit_Item_Behaviors_MySobekViewer(user, Current_Mode, currentItem, codeManager, Tracer); break; case My_Sobek_Type_Enum.Edit_Item_Metadata: mySobekViewer = new Edit_Item_Metadata_MySobekViewer(user, Current_Mode, itemList, currentItem, codeManager, iconTable, htmlSkin, Tracer); break; case My_Sobek_Type_Enum.File_Management: mySobekViewer = new File_Management_MySobekViewer(user, Current_Mode, Current_Item, itemList, codeManager, iconTable, htmlSkin, translator, Tracer); break; case My_Sobek_Type_Enum.Edit_Group_Behaviors: mySobekViewer = new Edit_Group_Behaviors_MySobekViewer(user, Current_Mode, currentItem, codeManager, Tracer); break; case My_Sobek_Type_Enum.Edit_Group_Serial_Hierarchy: mySobekViewer = new Edit_Serial_Hierarchy_MySobekViewer(user); break; case My_Sobek_Type_Enum.Group_Add_Volume: // Pull the list of items tied to this group SobekCM_Items_In_Title itemsInTitle = Cached_Data_Manager.Retrieve_Items_In_Title(currentItem.BibID, Tracer); if (itemsInTitle == null) { // Get list of information about this item group and save the item list DataSet itemDetails = SobekCM_Database.Get_Item_Group_Details(currentItem.BibID, Tracer); itemsInTitle = new SobekCM_Items_In_Title(itemDetails.Tables[1]); // Store in cache if retrieved Cached_Data_Manager.Store_Items_In_Title(currentItem.BibID, itemsInTitle, Tracer); } mySobekViewer = new Group_Add_Volume_MySobekViewer(user, Current_Mode, itemList, currentItem, codeManager, iconTable, htmlSkin, itemsInTitle, translator, Tracer); break; case My_Sobek_Type_Enum.Group_AutoFill_Volumes: mySobekViewer = new Group_AutoFill_Volume_MySobekViewer(user); break; case My_Sobek_Type_Enum.Group_Mass_Update_Items: mySobekViewer = new Mass_Update_Items_MySobekViewer(user, Current_Mode, currentItem, codeManager, Tracer); break; case My_Sobek_Type_Enum.User_Tags: mySobekViewer = new User_Tags_MySobekViewer(user, Tracer); break; case My_Sobek_Type_Enum.User_Usage_Stats: mySobekViewer = new User_Usage_Stats_MySobekViewer(user, Current_Mode, statsDates, Tracer); break; } // Pass in the navigation and translator information mySobekViewer.CurrentMode = Current_Mode; mySobekViewer.Translator = translator; }
/// <summary> Constructor for a new instance of the Admin_HtmlSubwriter class </summary> /// <param name="Results_Statistics"> Information about the entire set of results for a browse of a user's bookshelf folder </param> /// <param name="Paged_Results"> Single page of results for a browse of a user's bookshelf folder, within the entire set </param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="All_Items_Lookup"> Lookup object used to pull basic information about any item loaded into this library </param> /// <param name="Hierarchy_Object"> Current item aggregation object to display </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item">Current item to edit, if the user is requesting to edit an item</param> /// <param name="Aggregation_Aliases"> List of all existing aliases for existing aggregations </param> /// <param name="Web_Skin_Collection"> Collection of all the web skins </param> /// <param name="Current_User"> Currently logged on user </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="IP_Restrictions"> List of all IP Restriction ranges in use by this digital library </param> /// <param name="URL_Portals"> List of all web portals into this system </param> /// <param name="Stats_Date_Range"> Object contains the start and end dates for the statistical data in the database </param> /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public Admin_HtmlSubwriter(Search_Results_Statistics Results_Statistics, List <iSearch_Title_Result> Paged_Results, Aggregation_Code_Manager Code_Manager, Item_Lookup_Object All_Items_Lookup, Item_Aggregation Hierarchy_Object, SobekCM_Skin_Object HTML_Skin, Language_Support_Info Translator, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Dictionary <string, string> Aggregation_Aliases, SobekCM_Skin_Collection Web_Skin_Collection, User_Object Current_User, IP_Restriction_Ranges IP_Restrictions, Dictionary <string, Wordmark_Icon> Icon_Table, Portal_List URL_Portals, Statistics_Dates Stats_Date_Range, List <Thematic_Heading> Thematic_Headings, Custom_Tracer Tracer) { Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Saving values and geting user object back from the session"); resultsStatistics = Results_Statistics; pagedResults = Paged_Results; codeManager = Code_Manager; itemList = All_Items_Lookup; htmlSkin = HTML_Skin; translator = Translator; currentCollection = Hierarchy_Object; currentItem = Current_Item; user = Current_User; ipRestrictions = IP_Restrictions; iconTable = Icon_Table; statsDates = Stats_Date_Range; if (Current_Mode.My_Sobek_Type == My_Sobek_Type_Enum.Log_Out) { Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Performing logout"); HttpContext.Current.Session["user"] = null; HttpContext.Current.Response.Redirect("?"); } if ((Current_Mode.My_Sobek_Type != My_Sobek_Type_Enum.Logon) && (user != null) && (user.Is_Temporary_Password)) { Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.New_Password; } if (Current_Mode.Logon_Required) { Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Logon; } // If the user is not an admin, and admin was selected, reroute this if ((!Current_User.Is_System_Admin) && (!Current_User.Is_Portal_Admin)) { Current_Mode.Mode = Display_Mode_Enum.My_Sobek; Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; Current_Mode.My_Sobek_SubMode = String.Empty; HttpContext.Current.Response.Redirect(Current_Mode.Redirect_URL()); } Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Building the my sobek viewer object"); switch (Current_Mode.Admin_Type) { case Admin_Type_Enum.Aggregation_Single: adminViewer = new Aggregation_Single_AdminViewer(user, Current_Mode, codeManager, Thematic_Headings, Web_Skin_Collection, Tracer); break; case Admin_Type_Enum.Home: adminViewer = new Home_AdminViewer(user, Current_Mode, Tracer); break; case Admin_Type_Enum.Builder_Status: adminViewer = new Builder_AdminViewer(user, Current_Mode); break; case Admin_Type_Enum.Interfaces: adminViewer = new Skins_AdminViewer(user, Current_Mode, Web_Skin_Collection, Tracer); break; case Admin_Type_Enum.Forwarding: adminViewer = new Aliases_AdminViewer(user, Current_Mode, Aggregation_Aliases, Tracer); break; case Admin_Type_Enum.Wordmarks: adminViewer = new Wordmarks_AdminViewer(user, Current_Mode, Tracer); break; case Admin_Type_Enum.URL_Portals: adminViewer = new Portals_AdminViewer(user, Current_Mode, URL_Portals, Tracer); break; case Admin_Type_Enum.Users: adminViewer = new Users_AdminViewer(user, Current_Mode, codeManager, Tracer); break; case Admin_Type_Enum.User_Groups: adminViewer = new User_Group_AdminViewer(user, Current_Mode, codeManager, Tracer); break; case Admin_Type_Enum.Aggregations_Mgmt: adminViewer = new Aggregations_Mgmt_AdminViewer(user, Current_Mode, codeManager, Tracer); break; case Admin_Type_Enum.IP_Restrictions: adminViewer = new IP_Restrictions_AdminViewer(user, Current_Mode, ipRestrictions, Tracer); break; case Admin_Type_Enum.Thematic_Headings: adminViewer = new Thematic_Headings_AdminViewer(user, Current_Mode, Thematic_Headings, Tracer); break; case Admin_Type_Enum.Settings: adminViewer = new Settings_AdminViewer(user, Current_Mode, Tracer); break; case Admin_Type_Enum.Projects: if (Current_Mode.My_Sobek_SubMode.Length > 1) { string project_code = Current_Mode.My_Sobek_SubMode.Substring(1); Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Checking cache for valid project file"); if (user != null) { SobekCM_Item projectObject = Cached_Data_Manager.Retrieve_Project(user.UserID, project_code, Tracer); if (projectObject != null) { Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Valid project file found in cache"); adminViewer = new Edit_Item_Metadata_MySobekViewer(user, Current_Mode, itemList, projectObject, codeManager, iconTable, htmlSkin, Tracer); } else { if (SobekCM_Database.Get_All_Projects_Templates(Tracer).Tables[0].Select("ProjectCode='" + project_code + "'").Length > 0) { Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Building project file from (possible) PMETS"); string pmets_file = SobekCM_Library_Settings.Base_MySobek_Directory + "projects\\" + Current_Mode.My_Sobek_SubMode.Substring(1) + ".pmets"; SobekCM_Item pmets_item = File.Exists(pmets_file) ? SobekCM_Item.Read_METS(pmets_file) : new SobekCM_Item(); pmets_item.Bib_Info.Main_Title.Title = "Project level metadata for '" + project_code + "'"; pmets_item.Bib_Info.SobekCM_Type = TypeOfResource_SobekCM_Enum.Project; pmets_item.BibID = project_code.ToUpper(); pmets_item.VID = "00001"; pmets_item.Source_Directory = SobekCM_Library_Settings.Base_MySobek_Directory + "projects\\"; Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Adding project file to cache"); Cached_Data_Manager.Store_Project(user.UserID, project_code, pmets_item, Tracer); adminViewer = new Edit_Item_Metadata_MySobekViewer(user, Current_Mode, itemList, pmets_item, codeManager, iconTable, htmlSkin, Tracer); } } } } if (adminViewer == null) { adminViewer = new Projects_AdminViewer(user, Current_Mode, Tracer); } break; } // Pass in the navigation and translator information adminViewer.CurrentMode = Current_Mode; adminViewer.Translator = translator; }
/// <summary> Constructor for a new instance of the Edit_Item_Metadata_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="All_Items_Lookup"> Allows individual items to be retrieved by various methods as <see cref="Single_Item"/> objects.</param> /// <param name="Current_Item"> Individual digital resource to be edited by the user </param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="HTML_Skin_Collection"> HTML Web skin collection which controls the overall appearance of this digital library </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Edit_Item_Metadata_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Item_Lookup_Object All_Items_Lookup, SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Dictionary <string, Wordmark_Icon> Icon_Table, SobekCM_Skin_Object HTML_Skin, Language_Support_Info Translator, SobekCM_Skin_Collection HTML_Skin_Collection, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", String.Empty); currentMode = Current_Mode; item = Current_Item; itemList = All_Items_Lookup; codeManager = Code_Manager; iconList = Icon_Table; webSkin = HTML_Skin; popUpFormsHtml = String.Empty; delayed_popup = String.Empty; base.Translator = Translator; skins = HTML_Skin_Collection; // If the user cannot edit this item, go back if (!user.Can_Edit_This_Item(item)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // Is this a project isProject = item.Bib_Info.SobekCM_Type == TypeOfResource_SobekCM_Enum.Project; string template_code = user.Edit_Template_Code; if ((isProject) || (item.Contains_Complex_Content) || (item.Using_Complex_Template)) { template_code = user.Edit_Template_MARC_Code; } template = Cached_Data_Manager.Retrieve_Template(template_code, Tracer); if (template != null) { Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Found template in cache"); } else { Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Reading template file"); // Read this template Template_XML_Reader reader = new Template_XML_Reader(); template = new Template(); reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\edit\\" + template_code + ".xml", template, true); // Add the current codes to this template template.Add_Codes(Code_Manager); // Save this into the cache Cached_Data_Manager.Store_Template(template_code, template, Tracer); } // Get the current page number, or default to 1 page = 1; if (currentMode.My_Sobek_SubMode.Length > 0) { if ((currentMode.My_Sobek_SubMode == "preview") || (currentMode.My_Sobek_SubMode == "marc") || (currentMode.My_Sobek_SubMode == "mets")) { page = 0; } else { page = 1; bool isNumber = currentMode.My_Sobek_SubMode.All(Char.IsNumber); if (isNumber) { if (isProject) { Double.TryParse(currentMode.My_Sobek_SubMode[0].ToString(), out page); } else { Double.TryParse(currentMode.My_Sobek_SubMode, out page); } } else if (isProject) { if (Char.IsNumber(currentMode.My_Sobek_SubMode[0])) { Double.TryParse(currentMode.My_Sobek_SubMode[0].ToString(), out page); } } } } // Handle post backs if (Current_Mode.isPostBack) { // See if there was a hidden request string hidden_request = HttpContext.Current.Request.Form["new_element_requested"] ?? String.Empty; // If this was a cancel request do that if (hidden_request == "cancel") { if (isProject) { Cached_Data_Manager.Remove_Project(user.UserID, item.BibID, null); currentMode.Mode = Display_Mode_Enum.Administrative; currentMode.Admin_Type = Admin_Type_Enum.Default_Metadata; currentMode.My_Sobek_SubMode = String.Empty; currentMode.Redirect(); } else { Cached_Data_Manager.Remove_Digital_Resource_Object(user.UserID, item.BibID, item.VID, null); currentMode.Mode = Display_Mode_Enum.Item_Display; currentMode.Redirect(); } return; } // Save these changes to bib template.Save_To_Bib(item, user, ((int)page)); // See if the user asked for a new element of a complex form type delayed_popup = String.Empty; switch (hidden_request.Trim()) { case "name": delayed_popup = "name"; item.Bib_Info.Add_Named_Entity(String.Empty).Name_Type = Name_Info_Type_Enum.personal; break; case "title": delayed_popup = "title"; item.Bib_Info.Add_Other_Title(String.Empty, Title_Type_Enum.alternative); break; case "subject": delayed_popup = "subject"; item.Bib_Info.Add_Subject(); break; case "spatial": delayed_popup = "spatial"; item.Bib_Info.Add_Hierarchical_Geographic_Subject(); break; case "relateditem": delayed_popup = "relateditem"; item.Bib_Info.Add_Related_Item(new Related_Item_Info()); break; case "save": Complete_Item_Save(); break; case "complicate": item.Using_Complex_Template = true; HttpContext.Current.Response.Redirect("?" + HttpContext.Current.Request.QueryString, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); currentMode.Request_Completed = true; return; case "simplify": item.Using_Complex_Template = false; HttpContext.Current.Response.Redirect("?" + HttpContext.Current.Request.QueryString, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); currentMode.Request_Completed = true; return; } // Was this for a new page? if (hidden_request.IndexOf("newpage") == 0) { string page_requested = hidden_request.Replace("newpage", ""); if (page_requested != currentMode.My_Sobek_SubMode) { // forward to requested page currentMode.My_Sobek_SubMode = page_requested; if (currentMode.My_Sobek_SubMode == "0") { currentMode.My_Sobek_SubMode = "preview"; } if (isProject) { currentMode.My_Sobek_SubMode = page_requested + item.BibID; } HttpContext.Current.Response.Redirect(currentMode.Redirect_URL() + "#template", false); HttpContext.Current.ApplicationInstance.CompleteRequest(); currentMode.Request_Completed = true; } } } }
/// <summary> Constructor for a new instance of the User_Group_AdminViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="currentMode"> Mode / navigation information for the current request</param> /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> /// <remarks> Postback from a user group edit is handled here in the constructor </remarks> public User_Group_AdminViewer(User_Object User, SobekCM_Navigation_Object currentMode, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("User_Group_AdminViewer.Constructor", String.Empty); // Set the action message to clear initially actionMessage = String.Empty; codeManager = Code_Manager; // Get the user to edit, if there was a user id in the submode int edit_usergroupid = -100; editGroup = null; if (currentMode.My_Sobek_SubMode.Length > 0) { if (currentMode.My_Sobek_SubMode == "new") { edit_usergroupid = -1; } else { if (Int32.TryParse(currentMode.My_Sobek_SubMode.Replace("a", "").Replace("b", "").Replace("c", "").Replace("v", ""), out edit_usergroupid)) { editGroup = SobekCM_Database.Get_User_Group(edit_usergroupid, Tracer); } } } // Determine the mode mode = Users_Group_Admin_Mode_Enum.Error; if ((editGroup != null) || (edit_usergroupid == -1)) { if ((currentMode.My_Sobek_SubMode.IndexOf("v") > 0) && (edit_usergroupid > 0)) { mode = Users_Group_Admin_Mode_Enum.View_User_Group; } else { mode = Users_Group_Admin_Mode_Enum.Edit_User_Group; } } else { currentMode.My_Sobek_SubMode = String.Empty; currentMode.Admin_Type = Admin_Type_Enum.Users; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // Set an empty user group object for a new item if (edit_usergroupid < 0) { editGroup = new User_Group(String.Empty, String.Empty, -1); } // Perform post back work if (currentMode.isPostBack) { if ((mode == Users_Group_Admin_Mode_Enum.Edit_User_Group) && (editGroup != null)) { // Get a reference to this form NameValueCollection form = HttpContext.Current.Request.Form; string[] getKeys = form.AllKeys; bool successful_save = true; bool can_editall = editGroup.Editable_Regular_Expressions.Any(thisRegularExpression => thisRegularExpression == "[A-Z]{2}[A-Z|0-9]{4}[0-9]{4}"); bool can_submit = false; bool is_internal = false; bool is_admin = false; bool is_portal = false; string name = editGroup.Name; string description = editGroup.Description; List <string> projects = new List <string>(); List <string> templates = new List <string>(); Dictionary <string, User_Editable_Aggregation> aggregations = new Dictionary <string, User_Editable_Aggregation>(); // Step through each key foreach (string thisKey in getKeys) { switch (thisKey) { case "groupName": name = form[thisKey].Trim(); break; case "groupDescription": description = form[thisKey].Trim(); break; case "admin_user_submit": can_submit = true; break; case "admin_user_internal": is_internal = true; break; case "admin_user_editall": can_editall = true; break; case "admin_user_admin": is_admin = true; break; case "admin_user_portaladmin": is_portal = true; break; default: if (thisKey.IndexOf("admin_user_template_") == 0) { templates.Add(thisKey.Replace("admin_user_template_", "")); } if (thisKey.IndexOf("admin_user_project_") == 0) { projects.Add(thisKey.Replace("admin_user_project_", "")); } if (thisKey.IndexOf("admin_project_onhome_") == 0) { string select_project = thisKey.Replace("admin_project_onhome_", ""); if (aggregations.ContainsKey(select_project)) { aggregations[select_project].OnHomePage = true; } else { aggregations.Add(select_project, new User_Editable_Aggregation(select_project, String.Empty, false, false, false, true)); } } if (thisKey.IndexOf("admin_project_select_") == 0) { string select_project = thisKey.Replace("admin_project_select_", ""); if (aggregations.ContainsKey(select_project)) { aggregations[select_project].CanSelect = true; } else { aggregations.Add(select_project, new User_Editable_Aggregation(select_project, String.Empty, true, false, false, false)); } } if (thisKey.IndexOf("admin_project_edit_") == 0) { string edit_project = thisKey.Replace("admin_project_edit_", ""); if (aggregations.ContainsKey(edit_project)) { aggregations[edit_project].CanEditItems = true; } else { aggregations.Add(edit_project, new User_Editable_Aggregation(edit_project, String.Empty, false, true, false, false)); } } if (thisKey.IndexOf("admin_project_admin_") == 0) { string admin_project = thisKey.Replace("admin_project_admin_", ""); if (aggregations.ContainsKey(admin_project)) { aggregations[admin_project].IsCurator = true; } else { aggregations.Add(admin_project, new User_Editable_Aggregation(admin_project, String.Empty, false, false, true, false)); } } break; } } // Determine if the projects and templates need to be updated bool update_templates_projects = false; if ((templates.Count != editGroup.Templates.Count) || (projects.Count != editGroup.Projects.Count)) { update_templates_projects = true; } else { // Check all of the templates if (templates.Any(template => !editGroup.Templates.Contains(template))) { update_templates_projects = true; } // Check all the projects if (!update_templates_projects) { if (projects.Any(project => !editGroup.Projects.Contains(project))) { update_templates_projects = true; } } } // Determine if the aggregations need to be edited bool update_aggregations = false; if (aggregations.Count != editGroup.Aggregations.Count) { update_aggregations = true; } else { // Build a dictionary of the user aggregations as well Dictionary <string, User_Editable_Aggregation> existingAggr = editGroup.Aggregations.ToDictionary(thisAggr => thisAggr.Code); // Check all the aggregations foreach (User_Editable_Aggregation adminAggr in aggregations.Values) { if (existingAggr.ContainsKey(adminAggr.Code)) { if ((adminAggr.CanSelect != existingAggr[adminAggr.Code].CanSelect) || (adminAggr.CanEditItems != existingAggr[adminAggr.Code].CanEditItems) || (adminAggr.IsCurator != existingAggr[adminAggr.Code].IsCurator)) { update_aggregations = true; break; } } else { update_aggregations = true; break; } } } // Must have a name to continue if (name.Length > 0) { // Update the basic user information int newid = SobekCM_Database.Save_User_Group(editGroup.UserGroupID, name, description, can_submit, is_internal, can_editall, is_admin, is_portal, false, update_templates_projects, update_aggregations, false, Tracer); if (editGroup.UserGroupID < 0) { editGroup.UserGroupID = newid; } if (editGroup.UserGroupID > 0) { // Update the templates and projects, if requested if (update_templates_projects) { // Update projects, if necessary if (projects.Count > 0) { if (!SobekCM_Database.Update_SobekCM_User_Group_Projects(editGroup.UserGroupID, projects, Tracer)) { successful_save = false; } } // Update templates, if necessary if (templates.Count > 0) { if (!SobekCM_Database.Update_SobekCM_User_Group_Templates(editGroup.UserGroupID, templates, Tracer)) { successful_save = false; } } } // Update the aggregations, if requested if (update_aggregations) { if (aggregations.Count > 0) { List <User_Editable_Aggregation> aggregationList = aggregations.Values.ToList(); if (!SobekCM_Database.Update_SobekCM_User_Group_Aggregations(editGroup.UserGroupID, aggregationList, Tracer)) { successful_save = false; } } } } else { successful_save = false; } } else { actionMessage = "User group's name must have a length greater than zero"; successful_save = false; } // Forward back to the list of users, if this was successful if (successful_save) { currentMode.My_Sobek_SubMode = String.Empty; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } } } }
/// <summary> Constructor for a new instance of the 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="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> /// <remarks> Postback from handling an edit or new aggregation is handled here in the constructor </remarks> public Aggregations_Mgmt_AdminViewer(User_Object User, SobekCM_Navigation_Object CurrentMode, Aggregation_Code_Manager Code_Manager, List<Thematic_Heading> Thematic_Headings, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Aggregations_Mgmt_AdminViewer.Constructor", String.Empty); codeManager = Code_Manager; currentMode = CurrentMode; thematicHeadings = Thematic_Headings; // 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 == 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_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(); string delete_aggregation_code = String.Empty; if (form["admin_aggr_delete"] != null) delete_aggregation_code = form["admin_aggr_delete"].ToLower().Trim(); // Was this to delete the aggregation? if ( delete_aggregation_code.Length > 0) { string delete_error; int errorCode = SobekCM_Database.Delete_Item_Aggregation(delete_aggregation_code, user.Is_System_Admin, user.Full_Name, Tracer, out delete_error); if (errorCode <= 0) { string delete_folder = SobekCM_Library_Settings.Base_Design_Location + "aggregations\\" + delete_aggregation_code; if (SobekCM_File_Utilities.Delete_Folders_Recursively(delete_folder)) actionMessage = "Deleted '" + delete_aggregation_code + "' aggregation<br /><br />Unable to remove aggregation directory<br /><br />Some of the files may be in use"; else actionMessage = "Deleted '" + delete_aggregation_code + "' aggregation"; } else { actionMessage = delete_error; } // Reload the list of all codes, to include this new one and the new hierarchy lock (codeManager) { SobekCM_Database.Populate_Code_Manager(codeManager, Tracer); } } // 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 = true; // 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(); object 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 = false; } // 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"); } // Validate the code if (new_aggregation_code.Length > 20) { errors.Add("New aggregation code must be twenty characters long or less"); } else if (new_aggregation_code.Length == 0) { errors.Add("You must enter a CODE for this item aggregation"); } else if (codeManager[new_aggregation_code.ToUpper()] != null) { errors.Add("New code must be unique... <i>" + new_aggregation_code + "</i> already exists"); } else if (SobekCM_Library_Settings.Reserved_Keywords.Contains(new_aggregation_code.ToLower())) { errors.Add("That code is a system-reserved keyword. Try a different code."); } // 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; } // Get the thematic heading id (no checks here) int thematicHeadingId = -1; if (form["admin_aggr_heading"] != null) thematicHeadingId = Convert.ToInt32(form["admin_aggr_heading"]); // Try to save the new item aggregation if (SobekCM_Database.Save_Item_Aggregation(new_aggregation_code, new_name, new_shortname, new_description, thematicHeadingId, correct_type, is_active, is_hidden, new_link, parentid, user.Full_Name, 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, log on as the aggregation admin and hover over this text to edit it.<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"); // Try to create a new custom banner bool custom_banner_created = false; // Create the banner with the name of the collection if (Directory.Exists(SobekCM_Library_Settings.Application_Server_Network + "\\default\\banner_images")) { try { string[] banners = Directory.GetFiles(SobekCM_Library_Settings.Application_Server_Network + "\\default\\banner_images", "*.jpg"); if (banners.Length > 0) { Random randomizer = new Random(); string banner_to_use = banners[randomizer.Next(0, banners.Length - 1)]; Bitmap bitmap = (Bitmap)System.Drawing.Bitmap.FromFile(banner_to_use); RectangleF rectf = new RectangleF(30, bitmap.Height - 55, bitmap.Width - 40, 40); Graphics g = Graphics.FromImage(bitmap); g.SmoothingMode = SmoothingMode.AntiAlias; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.DrawString(new_name, new Font("Tahoma", 25, FontStyle.Bold), Brushes.Black, rectf); g.Flush(); string new_file = folder + "/images/banners/coll.jpg"; if (!File.Exists(new_file)) { bitmap.Save(new_file, ImageFormat.Jpeg); custom_banner_created = true; } } } catch (Exception ee) { string msg = ee.Message; } } if ((!custom_banner_created) && (!File.Exists(folder + "/images/banners/coll.jpg"))) { 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, false, Tracer); itemAggregation.Write_Configuration_File(SobekCM_Library_Settings.Base_Design_Location + itemAggregation.ObjDirectory); } } catch { actionMessage = "ERROR saving the new item aggregation to the database"; } // Reload the list of all codes, to include this new one and the new hierarchy lock (codeManager) { SobekCM_Database.Populate_Code_Manager(codeManager, Tracer); } if ( !String.IsNullOrEmpty(actionMessage)) 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 Mass_Update_Items_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item"> Individual digital resource to be edited by the user </param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Mass_Update_Items_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Mass_Update_Items_MySobekViewer.Constructor", String.Empty); currentMode = Current_Mode; // Since this is a mass update, just create a new empty item with the GroupID included // from the provided item SobekCM_Item emptyItem = new SobekCM_Item { BibID = Current_Item.BibID }; emptyItem.Web.GroupID = Current_Item.Web.GroupID; emptyItem.Bib_Info.Source.Code = String.Empty; emptyItem.Behaviors.CheckOut_Required_Is_Null = true; emptyItem.Behaviors.IP_Restriction_Membership_Is_Null = true; emptyItem.Behaviors.Dark_Flag_Is_Null = true; item = emptyItem; // If the user cannot edit this item, go back if (!user.Can_Edit_This_Item(Current_Item)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; currentMode.Redirect(); return; } const string TEMPLATE_CODE = "massupdate"; template = Cached_Data_Manager.Retrieve_Template(TEMPLATE_CODE, Tracer); if (template != null) { Tracer.Add_Trace("Mass_Update_Items_MySobekViewer.Constructor", "Found template in cache"); } else { Tracer.Add_Trace("Mass_Update_Items_MySobekViewer.Constructor", "Reading template file"); // Read this template Template_XML_Reader reader = new Template_XML_Reader(); template = new Template(); reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\defaults\\" + TEMPLATE_CODE + ".xml", template, true); // Add the current codes to this template template.Add_Codes(Code_Manager); // Save this into the cache Cached_Data_Manager.Store_Template(TEMPLATE_CODE, template, Tracer); } // See if there was a hidden request string hidden_request = HttpContext.Current.Request.Form["behaviors_request"] ?? String.Empty; // If this was a cancel request do that if (hidden_request == "cancel") { currentMode.Mode = Display_Mode_Enum.Item_Display; currentMode.Redirect(); } else if (hidden_request == "save") { // Save these changes to bib template.Save_To_Bib(item, user, 1); // Save the behaviors SobekCM_Database.Save_Behaviors(item, false, true); // Store on the caches (to replace the other) Cached_Data_Manager.Remove_Digital_Resource_Objects(item.BibID, Tracer); // Forward currentMode.Mode = Display_Mode_Enum.Item_Display; currentMode.Redirect(); } }
/// <summary> Constructor for a new instance of the Edit_Item_Behaviors_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item"> Individual digital resource to be edited by the user </param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Edit_Item_Behaviors_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", String.Empty); currentMode = Current_Mode; item = Current_Item; // If the user cannot edit this item, go back if (!user.Can_Edit_This_Item(item)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } const string templateCode = "itembehaviors"; template = Cached_Data_Manager.Retrieve_Template(templateCode, Tracer); if (template != null) { Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "Found template in cache"); } else { Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "Reading template file"); // Read this template Template_XML_Reader reader = new Template_XML_Reader(); template = new Template(); reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\defaults\\" + templateCode + ".xml", template, true); // Add the current codes to this template template.Add_Codes(Code_Manager); // Save this into the cache Cached_Data_Manager.Store_Template(templateCode, template, Tracer); } // See if there was a hidden request string hidden_request = HttpContext.Current.Request.Form["behaviors_request"] ?? String.Empty; // If this was a cancel request do that if (hidden_request == "cancel") { currentMode.Mode = Display_Mode_Enum.Item_Display; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } else if (hidden_request == "save") { // Changes to the tracking box require the metadata search citation be rebuilt for this item // so save the old tracking box information first string oldTrackingBox = item.Tracking.Tracking_Box; // Save these changes to bib template.Save_To_Bib(item, user, 1); // Save the behaviors SobekCM_Database.Save_Behaviors(item, item.Behaviors.Text_Searchable, false); // Save the serial hierarchy as well (sort of a behavior) SobekCM_Database.Save_Serial_Hierarchy_Information(item, item.Web.GroupID, item.Web.ItemID); // Did the tracking box change? if (item.Tracking.Tracking_Box != oldTrackingBox) { SobekCM_Database.Create_Full_Citation_Value(item.Web.ItemID); } // Remoe from the caches (to replace the other) Cached_Data_Manager.Remove_Digital_Resource_Object(item.BibID, item.VID, Tracer); // Also remove the list of volumes, since this may have changed Cached_Data_Manager.Remove_Items_In_Title(item.BibID, Tracer); // Forward currentMode.Mode = Display_Mode_Enum.Item_Display; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } }
/// <summary> Constructor for a new instance of the Edit_Item_Metadata_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="All_Items_Lookup"> Allows individual items to be retrieved by various methods as <see cref="Single_Item"/> objects.</param> /// <param name="Current_Item"> Individual digital resource to be edited by the user </param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Edit_Item_Metadata_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Item_Lookup_Object All_Items_Lookup, SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Dictionary <string, Wordmark_Icon> Icon_Table, SobekCM_Skin_Object HTML_Skin, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", String.Empty); currentMode = Current_Mode; item = Current_Item; itemList = All_Items_Lookup; codeManager = Code_Manager; iconList = Icon_Table; webSkin = HTML_Skin; popUpFormsHtml = String.Empty; // If the user cannot edit this item, go back if (!user.Can_Edit_This_Item(item)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // Is this a project isProject = false; if (item.Bib_Info.SobekCM_Type == TypeOfResource_SobekCM_Enum.Project) { isProject = true; } string template_code = user.Edit_Template_Code; if ((isProject) || (item.Contains_Complex_Content) || (item.Using_Complex_Template)) { template_code = user.Edit_Template_MARC_Code; } template = Cached_Data_Manager.Retrieve_Template(template_code, Tracer); if (template != null) { Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Found template in cache"); } else { Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Reading template file"); // Read this template Template_XML_Reader reader = new Template_XML_Reader(); template = new Template(); reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\" + template_code + ".xml", template, true); // Add the current codes to this template template.Add_Codes(Code_Manager); // Save this into the cache Cached_Data_Manager.Store_Template(template_code, template, Tracer); } // Get the current page number, or default to 1 page = 1; if (currentMode.My_Sobek_SubMode.Length > 0) { if ((currentMode.My_Sobek_SubMode == "preview") || (currentMode.My_Sobek_SubMode == "marc") || (currentMode.My_Sobek_SubMode == "mets")) { page = 0; } else { page = 1; bool isNumber = currentMode.My_Sobek_SubMode.All(Char.IsNumber); if (isNumber) { if (isProject) { Double.TryParse(currentMode.My_Sobek_SubMode[0].ToString(), out page); } else { Double.TryParse(currentMode.My_Sobek_SubMode, out page); } } else if (isProject) { if (Char.IsNumber(currentMode.My_Sobek_SubMode[0])) { Double.TryParse(currentMode.My_Sobek_SubMode[0].ToString(), out page); } } } } }
/// <summary> Constructor for a new instance of the New_Group_And_Item_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item"> Digital resource selected for file management </param> /// <param name="Item_List"> Allows individual items to be retrieved by various methods as <see cref="Single_Item"/> objects.</param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Page_Image_Upload_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Item_Lookup_Object Item_List, Aggregation_Code_Manager Code_Manager, Dictionary <string, Wordmark_Icon> Icon_Table, SobekCM_Skin_Object HTML_Skin, Language_Support_Info Translator, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Page_Image_Upload_MySobekViewer.Constructor", String.Empty); // Save the parameters codeManager = Code_Manager; itemList = Item_List; iconList = Icon_Table; currentMode = Current_Mode; webSkin = HTML_Skin; this.validationErrors = validationErrors; base.Translator = Translator; item = Current_Item; // 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 in process directory for this digitalResourceDirectory = SobekCM_Library_Settings.In_Process_Submission_Location + "\\" + User.UserName.Replace(".", "").Replace("@", "") + "\\uploadimages\\" + Current_Item.METS_Header.ObjectID; if (User.ShibbID.Trim().Length > 0) { digitalResourceDirectory = SobekCM_Library_Settings.In_Process_Submission_Location + "\\" + User.ShibbID + "\\uploadimages\\" + Current_Item.METS_Header.ObjectID; } // Make the folder for the user in process directory if (!Directory.Exists(digitalResourceDirectory)) { Directory.CreateDirectory(digitalResourceDirectory); } else { // Any post-processing to do? string[] files = Directory.GetFiles(digitalResourceDirectory); foreach (string thisFile in files) { FileInfo thisFileInfo = new FileInfo(thisFile); if ((thisFileInfo.Extension.ToUpper() == ".TIF") || (thisFileInfo.Extension.ToUpper() == ".TIFF")) { // Is there a JPEG and/or thumbnail? string jpeg = digitalResourceDirectory + "\\" + thisFileInfo.Name.Replace(thisFileInfo.Extension, "") + ".jpg"; string jpeg_thumbnail = digitalResourceDirectory + "\\" + thisFileInfo.Name.Replace(thisFileInfo.Extension, "") + "thm.jpg"; // Is one missing? if ((!File.Exists(jpeg)) || (!File.Exists(jpeg_thumbnail))) { try { var tiffImg = System.Drawing.Image.FromFile(thisFile); var mainImg = ScaleImage(tiffImg, SobekCM_Library_Settings.JPEG_Width, SobekCM_Library_Settings.JPEG_Height); mainImg.Save(jpeg, ImageFormat.Jpeg); var thumbnailImg = ScaleImage(tiffImg, 150, 400); thumbnailImg.Save(jpeg_thumbnail, ImageFormat.Jpeg); } catch (Exception) { bool error = true; } } } } } // If this is post-back, handle it if (currentMode.isPostBack) { string[] getKeys = HttpContext.Current.Request.Form.AllKeys; string file_name_from_keys = String.Empty; string label_from_keys = String.Empty; foreach (string thisKey in getKeys) { if (thisKey.IndexOf("upload_file") == 0) { file_name_from_keys = HttpContext.Current.Request.Form[thisKey]; } if (thisKey.IndexOf("upload_label") == 0) { label_from_keys = HttpContext.Current.Request.Form[thisKey]; } if ((file_name_from_keys.Length > 0) && (label_from_keys.Length > 0)) { HttpContext.Current.Session["file_" + item.Web.ItemID + "_" + file_name_from_keys.Trim()] = label_from_keys.Trim(); file_name_from_keys = String.Empty; label_from_keys = String.Empty; } if (thisKey == "url_input") { item.Bib_Info.Location.Other_URL = HttpContext.Current.Request.Form[thisKey]; } } string action = HttpContext.Current.Request.Form["action"]; if (action == "delete") { string filename = HttpContext.Current.Request.Form["phase"]; try { if (File.Exists(digitalResourceDirectory + "\\" + filename)) { File.Delete(digitalResourceDirectory + "\\" + filename); } // Forward currentMode.Redirect(); return; } catch { // Error was caught during attempted delete } } if (action == "next_phase") { int phase = Convert.ToInt32(HttpContext.Current.Request.Form["phase"]); switch (phase) { case 2: // Clear all the file keys in the temporary folder string[] allFiles = Directory.GetFiles(digitalResourceDirectory); foreach (string thisFile in allFiles) { try { File.Delete(thisFile); } catch { // Do nothing - not a fatal problem } } try { Directory.Delete(digitalResourceDirectory); } catch { // Do nothing - not a fatal problem } // Redirect to the item currentMode.Mode = Display_Mode_Enum.Item_Display; currentMode.Redirect(); break; case 9: if (!complete_item_submission(item, null)) { // Also clear the item from the cache Cached_Data_Manager.Remove_Digital_Resource_Object(item.BibID, item.VID, null); // Redirect to the item currentMode.Mode = Display_Mode_Enum.Item_Display; currentMode.ViewerCode = "qc"; currentMode.Redirect(); } break; } } } }
/// <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 for a new instance of the New_Group_And_Item_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item"> Digital resource selected for file management </param> /// <param name="Item_List"> Allows individual items to be retrieved by various methods as <see cref="Single_Item"/> objects.</param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public File_Management_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Item_Lookup_Object Item_List, Aggregation_Code_Manager Code_Manager, Dictionary <string, Wordmark_Icon> Icon_Table, SobekCM_Skin_Object HTML_Skin, Language_Support_Info Translator, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", String.Empty); // Save the parameters codeManager = Code_Manager; itemList = Item_List; iconList = Icon_Table; currentMode = Current_Mode; webSkin = HTML_Skin; this.validationErrors = validationErrors; base.Translator = Translator; item = Current_Item; digitalResourceDirectory = Current_Item.Source_Directory; // If the user cannot edit this item, go back if (!user.Can_Edit_This_Item(item)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // If this is post-back, handle it if (currentMode.isPostBack) { string[] getKeys = HttpContext.Current.Request.Form.AllKeys; string file_name_from_keys = String.Empty; string label_from_keys = String.Empty; foreach (string thisKey in getKeys) { if (thisKey.IndexOf("upload_file") == 0) { file_name_from_keys = HttpContext.Current.Request.Form[thisKey]; } if (thisKey.IndexOf("upload_label") == 0) { label_from_keys = HttpContext.Current.Request.Form[thisKey]; } if ((file_name_from_keys.Length > 0) && (label_from_keys.Length > 0)) { HttpContext.Current.Session["file_" + item.Web.ItemID + "_" + file_name_from_keys.Trim()] = label_from_keys.Trim(); file_name_from_keys = String.Empty; label_from_keys = String.Empty; } if (thisKey == "url_input") { item.Bib_Info.Location.Other_URL = HttpContext.Current.Request.Form[thisKey]; } } string action = HttpContext.Current.Request.Form["action"]; if (action == "delete") { string filename = HttpContext.Current.Request.Form["phase"]; try { if (File.Exists(digitalResourceDirectory + "\\" + filename)) { File.Delete(digitalResourceDirectory + "\\" + filename); } // Forward HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } catch { // Error was caught during attempted delete } } if (action == "next_phase") { int phase = Convert.ToInt32(HttpContext.Current.Request.Form["phase"]); switch (phase) { case 2: // Clear all the file keys in the session state List <string> keys = new List <string>(); foreach (string thisKey in HttpContext.Current.Session.Keys) { if (thisKey.IndexOf("file_" + item.Web.ItemID + "_") == 0) { keys.Add(thisKey); } } foreach (string thisKey in keys) { HttpContext.Current.Session.Remove(thisKey); } // Redirect to the item currentMode.Mode = Display_Mode_Enum.Item_Display; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); break; case 9: if (!complete_item_submission(item, null)) { // Clear all the file keys in the session state List <string> keys2 = new List <string>(); foreach (string thisKey in HttpContext.Current.Session.Keys) { if (thisKey.IndexOf("file_" + item.Web.ItemID + "_") == 0) { keys2.Add(thisKey); } } foreach (string thisKey in keys2) { HttpContext.Current.Session.Remove(thisKey); } // Also clear the item from the cache MemoryMgmt.Cached_Data_Manager.Remove_Digital_Resource_Object(item.BibID, item.VID, null); // Redirect to the item currentMode.Mode = Display_Mode_Enum.Item_Display; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } break; } } } }
/// <summary> Constructor for a new instance of the Edit_Group_Behaviors_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="Current_Item"> Individual digital resource to be edited by the user </param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Edit_Group_Behaviors_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Edit_Group_Behaviors_MySobekViewer.Constructor", String.Empty); currentMode = Current_Mode; item = Current_Item; // If the user cannot edit this item, go back if (!user.Can_Edit_This_Item(item)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; currentMode.Redirect(); return; } const string TEMPLATE_CODE = "groupbehaviors"; template = Cached_Data_Manager.Retrieve_Template(TEMPLATE_CODE, Tracer); if (template != null) { Tracer.Add_Trace("Edit_Group_Behaviors_MySobekViewer.Constructor", "Found template in cache"); } else { Tracer.Add_Trace("Edit_Group_Behaviors_MySobekViewer.Constructor", "Reading template file"); // Read this template Template_XML_Reader reader = new Template_XML_Reader(); template = new Template(); reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\defaults\\" + 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") { // Save these changes to bib template.Save_To_Bib(item, user, 1); // Save the group title SobekCM_Database.Update_Item_Group(item.BibID, item.Behaviors.GroupTitle, item.Bib_Info.SortSafeTitle(item.Behaviors.GroupTitle, true), String.Empty, item.Behaviors.Primary_Identifier.Type, item.Behaviors.Primary_Identifier.Identifier); // Save the interfaces to the group item as well SobekCM_Database.Save_Item_Group_Web_Skins(item.Web.GroupID, item); // Store on the caches (to replace the other) Cached_Data_Manager.Remove_Digital_Resource_Objects(item.BibID, Tracer); // Forward currentMode.Mode = Display_Mode_Enum.Item_Display; currentMode.Redirect(); } }
/// <summary> Constructor for a new instance of the Group_Add_Volume_MySobekViewer class </summary> /// <param name="User"> Authenticated user information </param> /// <param name="Current_Mode"> Mode / navigation information for the current request</param> /// <param name="All_Items_Lookup"> Allows individual items to be retrieved by various methods as <see cref="Single_Item"/> objects.</param> /// <param name="Current_Item"> Individual digital resource to be edited by the user </param> /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param> /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param> /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param> /// <param name="Items_In_Title"> List of items within this title </param> /// <param name="Translator"> Language support object which handles simple translational duties </param> /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param> public Group_Add_Volume_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Item_Lookup_Object All_Items_Lookup, SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Dictionary <string, Wordmark_Icon> Icon_Table, SobekCM_Skin_Object HTML_Skin, SobekCM_Items_In_Title Items_In_Title, Language_Support_Info Translator, Custom_Tracer Tracer) : base(User) { Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", String.Empty); currentMode = Current_Mode; item = Current_Item; itemList = All_Items_Lookup; codeManager = Code_Manager; iconList = Icon_Table; webSkin = HTML_Skin; itemsInTitle = Items_In_Title; base.Translator = Translator; // Set some defaults ipRestrict = -1; title = String.Empty; date = String.Empty; level1 = String.Empty; level2 = String.Empty; level3 = String.Empty; level1Order = -1; level2Order = -1; level3Order = -1; hierarchyCopiedFromDate = false; message = String.Empty; trackingBox = String.Empty; bornDigital = false; materialRecdDate = null; materialRecdNotes = String.Empty; dispositionAdvice = -1; dispositionAdviceNotes = String.Empty; // If the user cannot edit this item, go back if (!user.Can_Edit_This_Item(item)) { currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } // Determine the default template code string template_code = "addvolume"; if (!user.Include_Tracking_In_Standard_Forms) { template_code = "addvolume_notracking"; } // Load this template template = Cached_Data_Manager.Retrieve_Template(template_code, Tracer); if (template != null) { Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Found template in cache"); } else { Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Reading template file"); // Read this template Template_XML_Reader reader = new Template_XML_Reader(); template = new Template(); reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\defaults\\" + template_code + ".xml", template, true); // Add the current codes to this template template.Add_Codes(Code_Manager); // Save this into the cache Cached_Data_Manager.Store_Template(template_code, template, Tracer); } // See if there was a hidden request string hidden_request = HttpContext.Current.Request.Form["action"] ?? String.Empty; // If this was a cancel request do that if (hidden_request == "cancel") { currentMode.Mode = Display_Mode_Enum.Item_Display; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); } else if (hidden_request.IndexOf("save") == 0) { // Get the VID that used as a source for this string vid = HttpContext.Current.Request.Form["base_volume"]; if (string.IsNullOrEmpty(vid)) { message = "<span style=\"color: red\"><strong>No base volume selected!</strong></span>"; } else { try { // Get a new instance of this item SobekCM_Item saveItem = SobekCM_Item_Factory.Get_Item(Current_Mode.BibID, vid, Icon_Table, Tracer); // Clear some values for this item saveItem.VID = String.Empty; saveItem.Divisions.Clear(); saveItem.Behaviors.Serial_Info.Clear(); saveItem.Bib_Info.Series_Part_Info.Clear(); saveItem.Behaviors.Clear_Ticklers(); saveItem.Tracking.Internal_Comments = String.Empty; // Save the template changes to this item template.Save_To_Bib(saveItem, user, 1); // Save this item and copy over complete_item_submission(saveItem, Tracer); // Clear the volume list Cached_Data_Manager.Remove_Items_In_Title(saveItem.BibID, Tracer); // Forward differently depending on request switch (hidden_request) { case "save_edit": currentMode.Mode = Display_Mode_Enum.My_Sobek; currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Edit_Item_Metadata; currentMode.VID = saveItem.VID; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); break; case "save_again": // No redirect, but save values date = saveItem.Bib_Info.Origin_Info.Date_Issued; ipRestrict = saveItem.Behaviors.IP_Restriction_Membership; trackingBox = saveItem.Tracking.Tracking_Box; bornDigital = saveItem.Tracking.Born_Digital; dispositionAdvice = saveItem.Tracking.Disposition_Advice; dispositionAdviceNotes = saveItem.Tracking.Disposition_Advice_Notes; materialRecdDate = saveItem.Tracking.Material_Received_Date; materialRecdNotes = saveItem.Tracking.Material_Received_Notes; if (!hierarchyCopiedFromDate) { if (saveItem.Behaviors.Serial_Info.Count > 0) { level1 = saveItem.Behaviors.Serial_Info[0].Display; level1Order = saveItem.Behaviors.Serial_Info[0].Order; } if (saveItem.Behaviors.Serial_Info.Count > 1) { level2 = saveItem.Behaviors.Serial_Info[1].Display; level2Order = saveItem.Behaviors.Serial_Info[1].Order; } if (saveItem.Behaviors.Serial_Info.Count > 2) { level3 = saveItem.Behaviors.Serial_Info[2].Display; level3Order = saveItem.Behaviors.Serial_Info[2].Order; } } message = message + "<span style=\"color: blue\"><strong>Saved new volume ( " + saveItem.BibID + " : " + saveItem.VID + ")</strong></span>"; break; //case "save_addfiles": // break; default: currentMode.Mode = Display_Mode_Enum.Item_Display; currentMode.VID = saveItem.VID; HttpContext.Current.Response.Redirect(currentMode.Redirect_URL()); break; } } catch (Exception ee) { message = message + "<br /><span style=\"color: red\"><strong>EXCEPTION CAUGHT!<br /><br />" + ee.Message + "<br /><br />" + ee.StackTrace.Replace("\n", "<br />") + "</strong></span>"; } } } }
/// <summary> Constructor for a new instance of the 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 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"; } } }