/// <summary> Constructor for a new instance of the Admin_HtmlSubwriter class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> public Admin_HtmlSubwriter(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Saving values and geting RequestSpecificValues.Current_User object back from the session"); // All Admin pages require a RequestSpecificValues.Current_User being logged on if (RequestSpecificValues.Current_User == null) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Logon; RequestSpecificValues.Current_Mode.My_Sobek_SubMode = String.Empty; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // If the user is not an admin, and admin was selected, reroute this if ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin) && (RequestSpecificValues.Current_Mode.Admin_Type != Admin_Type_Enum.Aggregation_Single)) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; RequestSpecificValues.Current_Mode.My_Sobek_SubMode = String.Empty; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // Get the appropriate admin viewer from the factory adminViewer = AdminViewer_Factory.Get_AdminViewer(RequestSpecificValues); }
private void Complete_Item_Save() { if (isProject) { // Save the new project METS currentItem.Save_METS(); // Clear the cache of this item CachedDataManager.Remove_Project(RequestSpecificValues.Current_User.UserID, currentItem.BibID, null); // Redirect RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Administrative; RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Default_Metadata; RequestSpecificValues.Current_Mode.My_Sobek_SubMode = String.Empty; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } else { string error_message; SobekCM_Item_Updater.Update_Item(currentItem, RequestSpecificValues.Current_User, out error_message); CachedDataManager.Items.Remove_Digital_Resource_Object(RequestSpecificValues.Current_User.UserID, currentItem.BibID, currentItem.VID, null); // Also clear the engine SobekEngineClient.Items.Clear_Item_Cache(currentItem.BibID, currentItem.VID, RequestSpecificValues.Tracer); // Forward to the display item again RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display; RequestSpecificValues.Current_Mode.ViewerCode = "citation"; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } }
/// <summary> Constructor for a new instance of the Manage_Menu_AggregationViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="ViewBag"> Aggregation-specific request information, such as aggregation object and any browse object requested </param> public Manage_Menu_AggregationViewer(RequestCache RequestSpecificValues, AggregationViewBag ViewBag) : base(RequestSpecificValues, ViewBag) { // User must AT LEAST be logged on, return if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn)) { RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } }
public Rights_Management_MySobekViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { // With the user logged in at this point check for the permission, if not held, go back if (RequestSpecificValues.Current_User.Get_Setting("Rights_Management_MySobekViewer", string.Empty) != "true") { RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } }
/// <summary> Constructor for a new instance of the User_Permissions_AggregationViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="ViewBag"> Aggregation-specific request information, such as aggregation object and any browse object requested </param> public User_Permissions_AggregationViewer(RequestCache RequestSpecificValues, AggregationViewBag ViewBag) : base(RequestSpecificValues, ViewBag) { // User must AT LEAST be logged on, return if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn)) { RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // If the user is not an admin of some type, also return if ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin) && (!RequestSpecificValues.Current_User.Is_Aggregation_Curator(ViewBag.Hierarchy_Object.Code))) { RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } }
/// <summary> Constructor for a new instance of the Builder_AdminViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> public Builder_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { // Ensure the user is the system admin if ((RequestSpecificValues.Current_User == null) || ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin))) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // If this is a postback, handle any events first if (RequestSpecificValues.Current_Mode.isPostBack) { if (((RequestSpecificValues.Current_User.Is_System_Admin) && (!UI_ApplicationCache_Gateway.Settings.Servers.isHosted)) || (RequestSpecificValues.Current_User.Is_Host_Admin)) { // Pull the hidden value string save_value = HttpContext.Current.Request.Form["admin_builder_tosave"].ToUpper().Trim(); if (save_value.Length > 0) { // Set this value Engine_Database.Set_Setting("Builder Operation Flag", save_value); UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } } } page = 1; if (!String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.My_Sobek_SubMode)) { switch (RequestSpecificValues.Current_Mode.My_Sobek_SubMode.ToLower()) { case "b": page = 2; break; case "c": page = 3; break; } } }
/// <summary> Constructor for a new instance of the Preferences_HtmlSubwriter class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> public Preferences_HtmlSubwriter(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { // See if there was a hidden request string hidden_request = HttpContext.Current.Request.Form["hidden_request"] ?? String.Empty; if (hidden_request == "submit") { NameValueCollection form = HttpContext.Current.Request.Form; string language_option = form["languageDropDown"]; switch (language_option) { case "en": RequestSpecificValues.Current_Mode.Language = Web_Language_Enum.English; break; case "fr": RequestSpecificValues.Current_Mode.Language = Web_Language_Enum.French; break; case "es": RequestSpecificValues.Current_Mode.Language = Web_Language_Enum.Spanish; break; } string defaultViewDropDown = form["defaultViewDropDown"]; HttpContext.Current.Session["User_Default_View"] = defaultViewDropDown; int user_sort = Convert.ToInt32(form["defaultSortDropDown"]); HttpContext.Current.Session["User_Default_Sort"] = user_sort; RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation; RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } }
/// <summary> Add controls directly to the form in the main control area placeholder </summary> /// <param name="MainPlaceHolder"> Main place holder to which all main controls are added </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param> /// <remarks> The bulk of this page is added here, as controls </remarks> public override void Add_Controls(PlaceHolder MainPlaceHolder, Custom_Tracer Tracer) { Tracer.Add_Trace("NewPassword_MySobekViewer.Add_Controls", ""); User_Object user = RequestSpecificValues.Current_User; // Is this for registration? bool registration = (HttpContext.Current.Session["user"] == null); if (registration) { user = new User_Object(); } string current_password = String.Empty; string new_password = String.Empty; string new_password2 = String.Empty; if (RequestSpecificValues.Current_Mode.isPostBack) { // Loop through and get the dataa string[] getKeys = HttpContext.Current.Request.Form.AllKeys; foreach (string thisKey in getKeys) { switch (thisKey) { case "current_password_enter": current_password = HttpContext.Current.Request.Form[thisKey]; break; case "new_password_enter": new_password = HttpContext.Current.Request.Form[thisKey]; break; case "new_password_confirm": new_password2 = HttpContext.Current.Request.Form[thisKey]; break; } } if ((new_password.Trim().Length == 0) || (new_password2.Trim().Length == 0)) { validationErrors.Add("Select and confirm a new password"); } if (new_password != new_password2) { validationErrors.Add("New passwords do not match"); } else if ((new_password.Length < 8) && (new_password.Length > 0)) { validationErrors.Add("Password must be at least eight digits"); } if (validationErrors.Count == 0) { if (new_password == current_password) { validationErrors.Add("The new password cannot match the old password"); } } if (validationErrors.Count == 0) { bool success = SobekCM_Database.Change_Password(user.UserName, current_password, new_password, false, Tracer); if (success) { user.Is_Temporary_Password = false; // Forward back to their original URL (unless the original URL was this logon page) string raw_url = (HttpContext.Current.Request.RawUrl); if (raw_url.ToUpper().IndexOf("M=HML") > 0) { RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } else { HttpContext.Current.Response.Redirect(HttpContext.Current.Request.RawUrl, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); RequestSpecificValues.Current_Mode.Request_Completed = true; return; } } else { validationErrors.Add("Unable to change password. Verify current password."); } } } StringBuilder literalBuilder = new StringBuilder(1000); literalBuilder.AppendLine("<script src=\"" + Static_Resources_Gateway.Sobekcm_Metadata_Js + "\" type=\"text/javascript\"></script>"); literalBuilder.AppendLine("<div class=\"SobekHomeText\" >"); literalBuilder.AppendLine("<br />"); literalBuilder.AppendLine("<blockquote>"); literalBuilder.AppendLine(user.Is_Temporary_Password ? "You are required to change your password to continue." : "Please enter your existing password and your new password."); if (validationErrors.Count > 0) { literalBuilder.AppendLine("<br /><br /><strong><span style=\"color: Red\">The following errors were detected:"); literalBuilder.AppendLine("<blockquote>"); foreach (string thisError in validationErrors) { literalBuilder.AppendLine(thisError + "<br />"); } literalBuilder.AppendLine("</blockquote>"); literalBuilder.AppendLine("</span></strong>"); } literalBuilder.AppendLine("</blockquote>"); literalBuilder.AppendLine("<table width=\"700px\"><tr><td width=\"180px\"> </td>"); literalBuilder.AppendLine("<td width=\"200px\"><label for=\"current_password_enter\">Existing Password:</label></td>"); literalBuilder.AppendLine("<td width=\"180px\">"); LiteralControl literal1 = new LiteralControl(literalBuilder.ToString()); literalBuilder.Remove(0, literalBuilder.Length); MainPlaceHolder.Controls.Add(literal1); existingPasswordBox = new TextBox { CssClass = "preferences_small_input", ID = "current_password_enter", TextMode = TextBoxMode.Password }; existingPasswordBox.Attributes.Add("onfocus", "textbox_enter('current_password_enter', 'preferences_small_input_focused')"); existingPasswordBox.Attributes.Add("onblur", "textbox_leave('current_password_enter', 'preferences_small_input')"); MainPlaceHolder.Controls.Add(existingPasswordBox); LiteralControl literal2 = new LiteralControl("</td><td width=\"140px\"> </td></tr>" + Environment.NewLine + "<tr><td> </td><td><label for=\"new_password_enter\">New Password:</label></td><td>"); MainPlaceHolder.Controls.Add(literal2); passwordBox = new TextBox { CssClass = "preferences_small_input", ID = "new_password_enter", TextMode = TextBoxMode.Password }; passwordBox.Attributes.Add("onfocus", "textbox_enter('new_password_enter', 'preferences_small_input_focused')"); passwordBox.Attributes.Add("onblur", "textbox_leave('new_password_enter', 'preferences_small_input')"); MainPlaceHolder.Controls.Add(passwordBox); LiteralControl literal3 = new LiteralControl("</td><td> </td></tr>" + Environment.NewLine + "<tr><td> </td><td><label for=\"new_password_confirm\">Confirm New Password:</label></td><td>"); MainPlaceHolder.Controls.Add(literal3); confirmPasswordBox = new TextBox { CssClass = "preferences_small_input", ID = "new_password_confirm", TextMode = TextBoxMode.Password }; confirmPasswordBox.Attributes.Add("onfocus", "textbox_enter('new_password_confirm', 'preferences_small_input_focused')"); confirmPasswordBox.Attributes.Add("onblur", "textbox_leave('new_password_confirm', 'preferences_small_input')"); MainPlaceHolder.Controls.Add(confirmPasswordBox); literalBuilder.AppendLine(" </td><td> </td></tr>"); literalBuilder.AppendLine(" <tr align=\"right\" valign=\"bottom\" height=\"50px\" ><td colspan=\"3\">"); RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Log_Out; literalBuilder.AppendLine(" <a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "\"><img src=\"" + RequestSpecificValues.Current_Mode.Base_URL + "design/skins/" + RequestSpecificValues.Current_Mode.Base_Skin_Or_Skin + "/buttons/cancel_button.gif\" border=\"0\" alt=\"CANCEL\" /></a> "); RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.New_Password; LiteralControl literal4 = new LiteralControl(literalBuilder.ToString()); MainPlaceHolder.Controls.Add(literal4); // Add the submit button ImageButton submitButton = new ImageButton { ImageUrl = RequestSpecificValues.Current_Mode.Base_URL + "design/skins/" + RequestSpecificValues.Current_Mode.Base_Skin_Or_Skin + "/buttons/save_button.gif", AlternateText = "SAVE" }; submitButton.Click += submitButton_Click; MainPlaceHolder.Controls.Add(submitButton); LiteralControl literal5 = new LiteralControl("</td></tr></table></blockquote></div>\n\n<!-- Focus on current password text box -->\n<script type=\"text/javascript\">focus_element('current_password_enter');</script>\n\n"); MainPlaceHolder.Controls.Add(literal5); }
/// <summary> Constructor for a new instance of the Portals_AdminViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> public Portals_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("Portals_AdminViewer.Constructor", String.Empty); // Set action message to nothing to start and some defaults actionMessage = String.Empty; entered_portal_name = String.Empty; entered_sys_abbrev = String.Empty; entered_web_skin = String.Empty; entered_aggregation = String.Empty; entered_url_segment = String.Empty; entered_base_purl = String.Empty; // If the RequestSpecificValues.Current_User cannot edit this, go back if ((RequestSpecificValues.Current_User == null) || ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin))) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } readOnlyMode = true; if (((RequestSpecificValues.Current_User.Is_System_Admin) && (!UI_ApplicationCache_Gateway.Settings.Servers.isHosted)) || (RequestSpecificValues.Current_User.Is_Host_Admin)) { readOnlyMode = false; } // Handle any post backs if (RequestSpecificValues.Current_Mode.isPostBack) { if (!readOnlyMode) { try { // Pull the standard values from the form NameValueCollection form = HttpContext.Current.Request.Form; string save_value = form["admin_portal_tosave"]; string action_value = form["admin_portal_action"]; // Switch, depending on the request if (action_value != null) { switch (action_value.Trim().ToLower()) { case "edit": // Get the values from the form for this new portal string edit_name = form["form_portal_name"].Trim(); string edit_abbr = form["form_portal_abbr"].Trim(); string edit_skin = form["form_portal_skin"].Trim(); string edit_aggr = String.IsNullOrEmpty(form["form_portal_aggregation"]) ? String.Empty : form["form_portal_aggregation"].Trim(); string edit_url = form["form_portal_url"].Trim(); string edit_purl = form["form_portal_purl"].Trim(); int portalid = Convert.ToInt32(save_value); // Look for this to see if this was the pre-existing default bool isDefault = UI_ApplicationCache_Gateway.URL_Portals.Default_Portal.ID == portalid; // Don't edit if the URL segment is empty and this is NOT default if ((!isDefault) && (edit_url.Trim().Length == 0)) { actionMessage = "ERROR: Non default portals MUST have a url segment associated."; } else if (edit_name.Length == 0) { actionMessage = "ERROR: Portal name is a REQUIRED field."; } else if (edit_abbr.Length == 0) { actionMessage = "ERROR: System abbreviation is a REQUIRED field"; } else { // Look for matching portal or URL segment names bool portal_name_match = false; bool url_segment_match = false; foreach (Portal thisPortal in UI_ApplicationCache_Gateway.URL_Portals.All_Portals) { if (thisPortal.ID != portalid) { if (String.Compare(thisPortal.Name, edit_name, true) == 0) { portal_name_match = true; break; } if (String.Compare(thisPortal.URL_Segment, edit_url, true) == 0) { url_segment_match = true; break; } } } if (portal_name_match) { actionMessage = "ERROR: Portal name must be unique, and that name is already in use"; } else if (url_segment_match) { actionMessage = "ERROR: URL segment must be unique, and that URL segment already exists"; } else { bool result = edit_abbr.All(C => Char.IsLetterOrDigit(C) || C == '_'); if (!result) { actionMessage = "ERROR: System abbreviation must include only letters and numbers"; edit_abbr = edit_abbr.Replace("\"", ""); } else { // Now, save this portal information int edit_id = SobekCM_Database.Edit_URL_Portal(portalid, edit_url, true, isDefault, edit_abbr, edit_name, edit_aggr, edit_skin, edit_purl, RequestSpecificValues.Tracer); if (edit_id > 0) { actionMessage = "Edited existing URL portal '" + edit_name + "'"; } else { actionMessage = "Error editing URL portal."; } } } } break; case "delete": actionMessage = SobekCM_Database.Delete_URL_Portal(Convert.ToInt32(save_value), RequestSpecificValues.Tracer) ? "URL portal deleted" : "Error deleting the URL portal"; break; case "new": // Get the values from the form for this new portal entered_portal_name = form["admin_portal_name"]; entered_sys_abbrev = form["admin_portal_abbr"]; entered_web_skin = form["admin_portal_skin"].ToLower(); entered_aggregation = form["admin_portal_aggregation"].ToLower(); entered_url_segment = form["admin_portal_url"]; entered_base_purl = form["admin_portal_purl"]; if (entered_portal_name.Length == 0) { actionMessage = "ERROR: Portal name is a REQUIRED field."; } else if (entered_sys_abbrev.Length == 0) { actionMessage = "ERROR: System abbreviation is a REQUIRED field."; } else if (entered_web_skin.Length == 0) { actionMessage = "ERROR: Default web skin is a REQUIRED field."; } else if (entered_url_segment.Length == 0) { actionMessage = "ERROR: URL segment is a REQUIRED field."; } else { // Look for matching portal or URL segment names bool portal_name_match = false; bool url_segment_match = false; foreach (Portal thisPortal in UI_ApplicationCache_Gateway.URL_Portals.All_Portals) { if (String.Compare(thisPortal.Name, entered_portal_name, true) == 0) { portal_name_match = true; break; } if (String.Compare(thisPortal.URL_Segment, entered_url_segment, true) == 0) { url_segment_match = true; break; } } if (portal_name_match) { actionMessage = "ERROR: Portal name must be unique, and that name is already in use"; } else if (url_segment_match) { actionMessage = "ERROR: URL segment must be unique, and that URL segment already exists"; } else { bool result = entered_sys_abbrev.All(C => Char.IsLetterOrDigit(C) || C == '_'); if (!result) { actionMessage = "ERROR: System abbreviation must include only letters and numbers"; entered_sys_abbrev = entered_sys_abbrev.Replace("\"", ""); } else { // Save this to the database int new_id = SobekCM_Database.Edit_URL_Portal(-1, entered_url_segment, true, false, entered_sys_abbrev, entered_portal_name, entered_aggregation, entered_web_skin, entered_base_purl, RequestSpecificValues.Tracer); if (new_id > 0) { actionMessage = "Saved new URL portal '" + entered_portal_name + "'"; entered_portal_name = String.Empty; entered_sys_abbrev = String.Empty; entered_web_skin = String.Empty; entered_aggregation = String.Empty; entered_url_segment = String.Empty; entered_base_purl = String.Empty; } else { actionMessage = "Error saving URL portal."; } } } } break; } } } catch { actionMessage = "Exception caught while handling request"; } // Reload all the URL UI_ApplicationCache_Gateway.URL_Portals Engine_Database.Populate_URL_Portals(UI_ApplicationCache_Gateway.URL_Portals, RequestSpecificValues.Tracer); } } }
/// <summary> Constructor for a new instance of the Contact_HtmlSubwriter class </summary> /// <param name="Last_Mode"> URL for the last mode this user was in before selecting contact us</param> /// <param name="UserHistoryRequestInfo"> Some history and user information to include in the final email </param> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> public Contact_HtmlSubwriter(string Last_Mode, string UserHistoryRequestInfo, RequestCache RequestSpecificValues) : base(RequestSpecificValues) { // Save the parameters lastMode = Last_Mode; // Set the error message to an empty string to start with errorMsg = String.Empty; // We need the aggregation here Item_Aggregation aggregation; if (!Get_Collection(RequestSpecificValues.Current_Mode, RequestSpecificValues.Tracer, out aggregation)) { aggregation = RequestSpecificValues.Top_Collection; } // Determine the configuration to use for this contact us form configuration = UI_ApplicationCache_Gateway.Configuration.ContactForm; if ((aggregation != null) && (aggregation.ContactForm != null)) { configuration = aggregation.ContactForm; } postBackValues = new Dictionary <string, string>(); foreach (string thisKey in HttpContext.Current.Request.Form.AllKeys) { if (thisKey != "item_action") { string value = HttpContext.Current.Request.Form[thisKey]; if (!String.IsNullOrEmpty(value)) { postBackValues[thisKey] = value; } } } // If this is a post back, send email if (HttpContext.Current.Request.Form["item_action"] == null) { return; } string action = HttpContext.Current.Request.Form["item_action"]; if (action == "email") { // Some values to collect information string subject = "Contact [" + RequestSpecificValues.Current_Mode.Instance_Abbreviation + " Submission]"; string message_from = RequestSpecificValues.Current_Mode.Instance_Abbreviation + "<" + UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromAddress + ">"; if (!String.IsNullOrEmpty(UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromDisplay)) { message_from = UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromDisplay + "<" + UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromAddress + ">"; } int text_area_count = configuration.TextAreaElementCount; StringBuilder emailBuilder = new StringBuilder(); // Make sure all the required fields are completed and build the emails StringBuilder errorBuilder = new StringBuilder(); int control_count = 1; foreach (ContactForm_Configuration_Element thisElement in configuration.FormElements) { if ((thisElement.Element_Type != ContactForm_Configuration_Element_Type_Enum.HiddenValue) && (thisElement.Element_Type != ContactForm_Configuration_Element_Type_Enum.ExplanationText)) { // Determine the name of this control string control_name = String.Empty; if (!String.IsNullOrEmpty(thisElement.Name)) { control_name = thisElement.Name.Replace(" ", "_"); } if (thisElement.Element_Type == ContactForm_Configuration_Element_Type_Enum.Subject) { control_name = "subject"; } if (thisElement.Element_Type == ContactForm_Configuration_Element_Type_Enum.Email) { control_name = "email"; } if (String.IsNullOrEmpty(control_name)) { control_name = "Control" + control_count; } if (!postBackValues.ContainsKey(control_name)) { if (thisElement.Required) { errorBuilder.Append(thisElement.QueryText.Get_Value(RequestSpecificValues.Current_Mode.Language).Replace(":", "") + "<br />"); } } else { if (thisElement.Element_Type == ContactForm_Configuration_Element_Type_Enum.Subject) { subject = postBackValues[control_name] + " [" + RequestSpecificValues.Current_Mode.Instance_Abbreviation + " Submission]"; } else if (thisElement.Element_Type == ContactForm_Configuration_Element_Type_Enum.Email) { string entered_message_from = postBackValues[control_name]; if (!IsValidEmail(entered_message_from)) { errorBuilder.Append(thisElement.QueryText.Get_Value(RequestSpecificValues.Current_Mode.Language).Replace(":", "") + " (INVALID) <br />"); } message_from = RequestSpecificValues.Current_Mode.Instance_Abbreviation + "<" + entered_message_from + ">"; if (!String.IsNullOrEmpty(UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromDisplay)) { message_from = UI_ApplicationCache_Gateway.Settings.Email.Setup.DefaultFromDisplay + "<" + entered_message_from + ">"; } emailBuilder.Append("Email:\t\t" + entered_message_from + "\n"); } else if (thisElement.Element_Type == ContactForm_Configuration_Element_Type_Enum.TextArea) { if (text_area_count == 1) { emailBuilder.Insert(0, postBackValues[control_name] + "\n\n"); } else { if (emailBuilder.Length > 0) { emailBuilder.Append("\n"); } emailBuilder.Append(thisElement.QueryText.Get_Value(RequestSpecificValues.Current_Mode.Language) + "\n"); emailBuilder.Append(postBackValues[control_name] + "\n\n"); } } else { emailBuilder.Append(control_name.Replace("_", " ") + ":\t\t" + postBackValues[control_name] + "\n"); } } control_count++; } } if (errorBuilder.Length > 0) { errorMsg = errorBuilder.ToString(); return; } // Create the final body string email_body = emailBuilder + "\n\n" + UserHistoryRequestInfo; // Determine the sendee string sendTo = UI_ApplicationCache_Gateway.Settings.Email.System_Email; if ((aggregation != null) && (!String.IsNullOrEmpty(aggregation.Contact_Email))) { sendTo = aggregation.Contact_Email.Replace(";", ","); } int userid = -1; if (RequestSpecificValues.Current_User != null) { userid = RequestSpecificValues.Current_User.UserID; } EmailInfo newEmail = new EmailInfo { Body = email_body, isContactUs = true, isHTML = false, RecipientsList = sendTo, Subject = subject, UserID = userid, FromAddress = message_from }; string error_msg; bool email_error = !Email_Helper.SendEmail(newEmail, out error_msg); // Send back to the home for this collection, sub, or group if (email_error) { HttpContext.Current.Response.Redirect(UI_ApplicationCache_Gateway.Settings.Servers.System_Error_URL, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); } else { // Send back to the home for this collection, sub, or group RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Contact_Sent; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } } }
/// <summary> Constructor for a new instance of the Edit_Item_Behaviors_MySobekViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> public Edit_Item_Behaviors_MySobekViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", String.Empty); // If no user then that is an error if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn)) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation; RequestSpecificValues.Current_Mode.Aggregation = String.Empty; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // Ensure BibID and VID provided RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "Validate provided bibid / vid"); if ((String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.BibID)) || (String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.VID))) { RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "BibID or VID was not provided!"); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error; RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : BibID/VID missing in item behavior request"; return; } RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "Try to pull this sobek complete item"); currentItem = SobekEngineClient.Items.Get_Sobek_Item(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Current_Mode.VID, RequestSpecificValues.Current_User.UserID, RequestSpecificValues.Tracer); if (currentItem == null) { RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "Unable to build complete item"); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error; RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : Unable to build complete item"; return; } // If no item, then an error occurred if (currentItem == null) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error; RequestSpecificValues.Current_Mode.Error_Message = "Invalid item indicated"; return; } // If the RequestSpecificValues.Current_User cannot edit this currentItem, go back if (!RequestSpecificValues.Current_User.Can_Edit_This_Item(currentItem.BibID, currentItem.Bib_Info.SobekCM_Type_String, currentItem.Bib_Info.Source.Code, currentItem.Bib_Info.HoldingCode, currentItem.Behaviors.Aggregation_Code_List)) { RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } const string TEMPLATE_CODE = "itembehaviors"; completeTemplate = Template_MemoryMgmt_Utility.Retrieve_Template(TEMPLATE_CODE, RequestSpecificValues.Tracer); if (completeTemplate != null) { RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "Found CompleteTemplate in cache"); } else { RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "Reading CompleteTemplate file"); // Look in the user-defined templates portion first string user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\user\\standard\\" + TEMPLATE_CODE + ".xml"; if (!File.Exists(user_template)) { user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\default\\standard\\" + TEMPLATE_CODE + ".xml"; } // Read this CompleteTemplate Template_XML_Reader reader = new Template_XML_Reader(); completeTemplate = new CompleteTemplate(); reader.Read_XML(user_template, completeTemplate, true); // Save this into the cache Template_MemoryMgmt_Utility.Store_Template(TEMPLATE_CODE, completeTemplate, RequestSpecificValues.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") { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } else if (hidden_request == "save") { // Changes to the tracking box require the metadata search citation be rebuilt for this currentItem // so save the old tracking box information first string oldTrackingBox = currentItem.Tracking.Tracking_Box; // Save these changes to bib completeTemplate.Save_To_Bib(currentItem, RequestSpecificValues.Current_User, 1); // Save the behaviors SobekCM_Item_Database.Save_Behaviors(currentItem, currentItem.Behaviors.Text_Searchable, false, false); // Save the serial hierarchy as well (sort of a behavior) SobekCM_Item_Database.Save_Serial_Hierarchy_Information(currentItem, currentItem.Web.GroupID, currentItem.Web.ItemID); // Did the tracking box change? if (currentItem.Tracking.Tracking_Box != oldTrackingBox) { SobekCM_Item_Database.Create_Full_Citation_Value(currentItem.Web.ItemID); } // Remoe from the caches (to replace the other) CachedDataManager.Items.Remove_Digital_Resource_Object(currentItem.BibID, currentItem.VID, RequestSpecificValues.Tracer); // Also remove the list of volumes, since this may have changed CachedDataManager.Items.Remove_Items_In_Title(currentItem.BibID, RequestSpecificValues.Tracer); CachedDataManager.Items.Remove_Items_List(currentItem.BibID, RequestSpecificValues.Tracer); // Also clear the engine SobekEngineClient.Items.Clear_Item_Group_Cache(currentItem.BibID, RequestSpecificValues.Tracer); // Also clear any searches or browses ( in the future could refine this to only remove those // that are impacted by this save... but this is good enough for now ) CachedDataManager.Clear_Search_Results_Browses(); // Forward RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } }
/// <summary> Constructor for a new instance of the Edit_Item_Metadata_MySobekViewer class </summary> /// <param name="DefaultMetadata"> Default metadata object, if that is how this is being used </param> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> public Edit_Item_Metadata_MySobekViewer(SobekCM_Item DefaultMetadata, RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", String.Empty); popUpFormsHtml = String.Empty; delayed_popup = String.Empty; // If no user then that is an error if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn)) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation; RequestSpecificValues.Current_Mode.Aggregation = String.Empty; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // If the default metadata was provided, use that if (DefaultMetadata != null) { currentItem = DefaultMetadata; } else { // Ensure BibID and VID provided RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Validate provided bibid / vid"); if ((String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.BibID)) || (String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.VID))) { RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "BibID or VID was not provided!"); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error; RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : BibID/VID missing in item metadata edit request"; return; } RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Try to pull this sobek complete item"); currentItem = SobekEngineClient.Items.Get_Sobek_Item(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Current_Mode.VID, RequestSpecificValues.Current_User.UserID, RequestSpecificValues.Tracer); if (currentItem == null) { RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Unable to build complete item"); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error; RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : Unable to build complete item"; return; } } // If the RequestSpecificValues.Current_User cannot edit this item, go back if (!RequestSpecificValues.Current_User.Can_Edit_This_Item(currentItem.BibID, currentItem.Bib_Info.SobekCM_Type_String, currentItem.Bib_Info.Source.Code, currentItem.Bib_Info.HoldingCode, currentItem.Behaviors.Aggregation_Code_List)) { RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; HttpContext.Current.Response.Redirect(UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode)); } // Is this a project isProject = currentItem.Bib_Info.SobekCM_Type == TypeOfResource_SobekCM_Enum.Project; string template_code = RequestSpecificValues.Current_User.Edit_Template_Code_Simple; if ((currentItem.Contains_Complex_Content) || (currentItem.Using_Complex_Template)) { template_code = RequestSpecificValues.Current_User.Edit_Template_Code_Complex; } if (isProject) { template_code = "standard_project"; completeTemplate = Template_MemoryMgmt_Utility.Retrieve_Template(template_code, RequestSpecificValues.Tracer); if (completeTemplate != null) { RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Found project-specific template in cache"); } else { RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Reading project-specific template file"); // Look in the user-defined portion string user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\user\\standard\\project.xml"; if (!File.Exists(user_template)) { user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\default\\standard\\project.xml"; } // Read this CompleteTemplate Template_XML_Reader reader = new Template_XML_Reader(); completeTemplate = new CompleteTemplate(); reader.Read_XML(user_template, completeTemplate, true); // Save this into the cache Template_MemoryMgmt_Utility.Store_Template(template_code, completeTemplate, RequestSpecificValues.Tracer); } } else { completeTemplate = Template_MemoryMgmt_Utility.Retrieve_Template(template_code, RequestSpecificValues.Tracer); if (completeTemplate != null) { RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Found template in cache"); } else { RequestSpecificValues.Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Reading template file"); // Look in the user-defined portion string user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\user\\edit\\" + template_code + ".xml"; if (!File.Exists(user_template)) { user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\default\\edit\\" + template_code + ".xml"; } // Read this CompleteTemplate Template_XML_Reader reader = new Template_XML_Reader(); completeTemplate = new CompleteTemplate(); reader.Read_XML(user_template, completeTemplate, true); if (completeTemplate != null) { completeTemplate.Build_Final_Adjustment_And_Checks(); } // Save this into the cache Template_MemoryMgmt_Utility.Store_Template(template_code, completeTemplate, RequestSpecificValues.Tracer); } } // Get the current page number, or default to 1 page = 1; if (!String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.My_Sobek_SubMode)) { if ((RequestSpecificValues.Current_Mode.My_Sobek_SubMode == "preview") || (RequestSpecificValues.Current_Mode.My_Sobek_SubMode == "marc") || (RequestSpecificValues.Current_Mode.My_Sobek_SubMode == "mets")) { page = 0; } else { page = 1; bool isNumber = RequestSpecificValues.Current_Mode.My_Sobek_SubMode.All(Char.IsNumber); if (isNumber) { if (isProject) { Double.TryParse(RequestSpecificValues.Current_Mode.My_Sobek_SubMode[0].ToString(), out page); } else { Double.TryParse(RequestSpecificValues.Current_Mode.My_Sobek_SubMode, out page); } } else if (isProject) { if (Char.IsNumber(RequestSpecificValues.Current_Mode.My_Sobek_SubMode[0])) { Double.TryParse(RequestSpecificValues.Current_Mode.My_Sobek_SubMode[0].ToString(), out page); } } } } // Handle post backs if (RequestSpecificValues.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) { CachedDataManager.Remove_Project(RequestSpecificValues.Current_User.UserID, currentItem.BibID, null); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Administrative; RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Default_Metadata; RequestSpecificValues.Current_Mode.My_Sobek_SubMode = String.Empty; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } else { CachedDataManager.Items.Remove_Digital_Resource_Object(RequestSpecificValues.Current_User.UserID, currentItem.BibID, currentItem.VID, null); // Also clear the engine SobekEngineClient.Items.Clear_Item_Cache(currentItem.BibID, currentItem.VID, RequestSpecificValues.Tracer); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } return; } // Save these changes to bib completeTemplate.Save_To_Bib(currentItem, RequestSpecificValues.Current_User, ((int)page)); // See if the RequestSpecificValues.Current_User asked for a new element of a complex form type delayed_popup = String.Empty; switch (hidden_request.Trim()) { case "name": delayed_popup = "name"; currentItem.Bib_Info.Add_Named_Entity(String.Empty).Name_Type = Name_Info_Type_Enum.Personal; break; case "title": delayed_popup = "title"; currentItem.Bib_Info.Add_Other_Title(String.Empty, Title_Type_Enum.Alternative); break; case "subject": delayed_popup = "subject"; currentItem.Bib_Info.Add_Subject(); break; case "spatial": delayed_popup = "spatial"; currentItem.Bib_Info.Add_Hierarchical_Geographic_Subject(); break; case "relateditem": delayed_popup = "relateditem"; currentItem.Bib_Info.Add_Related_Item(new Related_Item_Info()); break; case "save": Complete_Item_Save(); break; case "complicate": currentItem.Using_Complex_Template = true; HttpContext.Current.Response.Redirect("?" + HttpContext.Current.Request.QueryString, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); RequestSpecificValues.Current_Mode.Request_Completed = true; return; case "simplify": currentItem.Using_Complex_Template = false; HttpContext.Current.Response.Redirect("?" + HttpContext.Current.Request.QueryString, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); RequestSpecificValues.Current_Mode.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 != RequestSpecificValues.Current_Mode.My_Sobek_SubMode) { // forward to requested page RequestSpecificValues.Current_Mode.My_Sobek_SubMode = page_requested; if (RequestSpecificValues.Current_Mode.My_Sobek_SubMode == "0") { RequestSpecificValues.Current_Mode.My_Sobek_SubMode = "preview"; } if (isProject) { RequestSpecificValues.Current_Mode.My_Sobek_SubMode = page_requested + currentItem.BibID; } HttpContext.Current.Response.Redirect(UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode) + "#CompleteTemplate", false); HttpContext.Current.ApplicationInstance.CompleteRequest(); RequestSpecificValues.Current_Mode.Request_Completed = true; } } } }
/// <summary> Constructor for a new instance of the Home_MySobekViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> public Logon_MySobekViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { // Check to see if (non-admin) logon is currently disabled if (UI_ApplicationCache_Gateway.Settings.System.Disable_Standard_User_Logon_Flag) { generalLogonDisabled = true; generalLogonDisabledMsg = String.IsNullOrEmpty(UI_ApplicationCache_Gateway.Settings.System.Disable_Standard_User_Logon_Message) ? "General logon to this system is temporarily disabled." : UI_ApplicationCache_Gateway.Settings.System.Disable_Standard_User_Logon_Message; } else { generalLogonDisabled = false; generalLogonDisabledMsg = String.Empty; } RequestSpecificValues.Tracer.Add_Trace("Logon_MySobekViewer.Constructor", String.Empty); errorMessage = String.Empty; // If this is a postback, check to see if the user is valid if (RequestSpecificValues.Current_Mode.isPostBack) { string possible_username = String.Empty; string possible_password = String.Empty; bool remember_me = false; string[] getKeys = HttpContext.Current.Request.Form.AllKeys; foreach (string thisKey in getKeys) { switch (thisKey) { case "logon_username": possible_username = HttpContext.Current.Request.Form[thisKey].Trim(); break; case "logon_password": possible_password = HttpContext.Current.Request.Form[thisKey].Trim(); break; case "rememberme": if (HttpContext.Current.Request.Form[thisKey].Trim() == "rememberme") { remember_me = true; } break; } } if ((!String.IsNullOrEmpty(possible_password)) && (!String.IsNullOrEmpty(possible_username))) { User_Object user = Engine_Database.Get_User(possible_username, possible_password, RequestSpecificValues.Tracer); if (user != null) { // If disabled for general logon,cancel if ((generalLogonDisabled) && (!user.Is_Host_Admin) && (!user.Is_System_Admin)) { errorMessage = generalLogonDisabledMsg; return; } // The user was valid here, so save this user information HttpContext.Current.Session["user"] = user; // Should we remember this user via cookies? if (remember_me) { HttpCookie userCookie = new HttpCookie("SobekUser"); userCookie.Values["userid"] = user.UserID.ToString(); userCookie.Values["security_hash"] = user.Security_Hash(HttpContext.Current.Request.UserHostAddress); userCookie.Expires = DateTime.Now.AddDays(14); HttpContext.Current.Response.Cookies.Add(userCookie); } // Forward back to their original URL (unless the original URL was this logon page) string raw_url = HttpContext.Current.Items["Original_URL"].ToString(); if (raw_url.ToLower().IndexOf("my/logon") > 0) { if (!String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.Return_URL)) { HttpContext.Current.Response.Redirect(RequestSpecificValues.Current_Mode.Return_URL, false); RequestSpecificValues.Current_Mode.Request_Completed = true; return; } else { RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } } else { HttpContext.Current.Response.Redirect(raw_url, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); RequestSpecificValues.Current_Mode.Request_Completed = true; } } else { errorMessage = "Invalid user/password entered"; } } } }
/// <summary> Constructor for a new instance of the Delete_Verify_WebContentViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="StaticPage"> Static page info for this request </param> public Delete_Verify_WebContentViewer(RequestCache RequestSpecificValues, HTML_Based_Content StaticPage) : base(RequestSpecificValues, StaticPage) { // Pull the web content page if (RequestSpecificValues.Current_Mode.WebContentID.HasValue) { webContent = SobekEngineClient.WebContent.Get_HTML_Based_Content(RequestSpecificValues.Current_Mode.WebContentID.Value, true, RequestSpecificValues.Tracer); } // This should never occur, but just a double check if ((webContent == null) || (!webContent.WebContentID.HasValue)) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // Ensure there IS a logged on user RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Delete_Verify_WebContentViewer", "Validate user"); if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn)) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // If the user was logged on, but did not have permissions, show an error message canDelete = true; deleted = false; if (!webContent.Can_Delete(RequestSpecificValues.Current_User)) { errorMessage = "ERROR: You do not have permission to delete this page"; canDelete = false; } else if (HttpContext.Current.Request.RequestType == "POST") { string save_value = HttpContext.Current.Request.Form["admin_delete_item"]; // Better say "DELETE", or just send back to the item if ((save_value != null) && (String.Compare(save_value, "DELETE", StringComparison.OrdinalIgnoreCase) == 0)) { string entered_value = HttpContext.Current.Request.Form["admin_delete_confirm"]; if ((entered_value == null) || (entered_value.ToUpper() != "DELETE")) { errorMessage = "ERROR: To verify this deletion, type DELETE into the text box and press CONFIRM"; } else { string deleteReason = "Requested via web application"; RestResponseMessage message = SobekEngineClient.WebContent.Delete_HTML_Based_Content(webContent.WebContentID.Value, RequestSpecificValues.Current_User.Full_Name, deleteReason, RequestSpecificValues.Tracer); errorMessage = message.Message; if ((message.ErrorTypeEnum != ErrorRestTypeEnum.Successful) && (String.IsNullOrEmpty(errorMessage))) { errorMessage = "Error encountered on SobekCM engine."; } else { errorMessage = "Successfully deleted this web content page."; // Clear cached data here on the client CachedDataManager.WebContent.Clear_All_Web_Content_Lists(); CachedDataManager.WebContent.Clear_All_Web_Content_Pages(); CachedDataManager.WebContent.Clear_Page_Details(); UI_ApplicationCache_Gateway.WebContent_Hierarchy_Clear(); deleted = true; } } } } }
/// <summary> Constructor for a new instance of the WebContent_History_AdminViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <remarks> Postback from handling an edit or new aggregation is handled here in the constructor </remarks> public WebContent_History_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("WebContent_History_AdminViewer.Constructor", String.Empty); actionMessage = String.Empty; // Ensure the user is the system admin or portal admin if ((RequestSpecificValues.Current_User == null) || ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin))) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } //// If this is posted back, look for the reset //if (RequestSpecificValues.Current_Mode.isPostBack) //{ // string reset_value = HttpContext.Current.Request.Form[""]; // if ((!String.IsNullOrEmpty(reset_value)) && (reset_value == "reset")) // { // // Just ensure everything is emptied out // HttpContext.Current.Cache.Remove("GlobalPermissionsReport"); // HttpContext.Current.Cache.Remove("GlobalPermissionsUsersLinked"); // HttpContext.Current.Cache.Remove("GlobalPermissionsLinkedAggr"); // HttpContext.Current.Cache.Remove("GlobalPermissionsReportSubmit"); // } //} // Set filters initially to empty strings level1 = String.Empty; level2 = String.Empty; level3 = String.Empty; level4 = String.Empty; level5 = String.Empty; userFilter = String.Empty; // Get any userfilter if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["user"])) { userFilter = HttpContext.Current.Request.QueryString["user"]; } // If no user filter, try to find the level filters if (String.IsNullOrEmpty(userFilter)) { // Get any level filter information from the query string if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l1"])) { level1 = HttpContext.Current.Request.QueryString["l1"]; if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l2"])) { level2 = HttpContext.Current.Request.QueryString["l2"]; if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l3"])) { level3 = HttpContext.Current.Request.QueryString["l3"]; if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l4"])) { level4 = HttpContext.Current.Request.QueryString["l4"]; if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l5"])) { level5 = HttpContext.Current.Request.QueryString["l5"]; } } } } } } }
/// <summary> Constructor for a new instance of the Delete_Item_MySobekViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> public Delete_Item_MySobekViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Delete this item"); // Save mode and set defaults errorCode = -1; // Ensure BibID and VID provided RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Validate provided bibid / vid"); if ((String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.BibID)) || (String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.VID))) { RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "BibID or VID was not provided!"); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error; RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : BibID/VID missing in item behavior request"; return; } // Try to pull the item RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Try to pull this brief item"); int statusCode; itemToDelete = SobekEngineClient.Items.Get_Item_Brief(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Current_Mode.VID, true, RequestSpecificValues.Tracer, out statusCode); if (itemToDelete == null) { RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Unable to pull brief item from the engine"); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error; RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : Unable to pull brief item from the engine"; return; } // Second, ensure this is a logged on user and system administrator before continuing RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "Validate user permissions"); if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn)) { RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "User does not have delete permissions", Custom_Trace_Type_Enum.Error); errorCode = 1; } else { bool canDelete = false; if ((RequestSpecificValues.Current_User.Can_Delete_All) || (RequestSpecificValues.Current_User.Is_System_Admin)) { canDelete = true; } else { try { if (RequestSpecificValues.Current_User.Can_Edit_This_Item(itemToDelete.BibID, itemToDelete.Type, itemToDelete.Behaviors.Source_Institution_Aggregation, itemToDelete.Behaviors.Holding_Location_Aggregation, itemToDelete.Behaviors.Aggregation_Code_List)) { canDelete = true; } } catch { canDelete = false; } } if (!canDelete) { RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Constructor", "User does not have delete permissions", Custom_Trace_Type_Enum.Error); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation; RequestSpecificValues.Current_Mode.Aggregation = String.Empty; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } } // If this is a postback, handle any events first if ((RequestSpecificValues.Current_Mode.isPostBack) && (errorCode < 0)) { Debug.Assert(RequestSpecificValues.Current_User != null, "User != null"); // Pull the standard values string save_value = HttpContext.Current.Request.Form["admin_delete_item"]; string text_value = HttpContext.Current.Request.Form["admin_delete_confirm"]; // Better say "DELETE", or just send back to the item if ((save_value == null) || (save_value.ToUpper() != "DELETE") || (text_value.ToUpper() != "DELETE")) { HttpContext.Current.Response.Redirect(RequestSpecificValues.Current_Mode.Base_URL + RequestSpecificValues.Current_Mode.BibID + "/" + RequestSpecificValues.Current_Mode.VID, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); RequestSpecificValues.Current_Mode.Request_Completed = true; } else { if (RequestSpecificValues.Current_Mode.BibID.ToUpper() == "TEMP000001") { for (int deleteVID = 2124; deleteVID <= 2134; deleteVID++) { RequestSpecificValues.Current_Mode.VID = deleteVID.ToString().PadLeft(5, '0'); Delete_Item(); } } else { Delete_Item(); } } } }
/// <summary> Constructor for a new instance of the IP_Restrictions_AdminViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <remarks> Postback from handling an edit or new item aggregation alias is handled here in the constructor </remarks> public IP_Restrictions_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("IP_Restrictions_AdminViewer.Constructor", String.Empty); // Set some defaults entered_title = String.Empty; entered_notes = String.Empty; entered_message = String.Empty; // Ensure the RequestSpecificValues.Current_User is the system admin if ((RequestSpecificValues.Current_User == null) || ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin))) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // Determine if there is an specific IP address range for editing int index = -1; if (!String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.My_Sobek_SubMode)) { if (!Int32.TryParse(RequestSpecificValues.Current_Mode.My_Sobek_SubMode, out index)) { index = -1; } } // If there was an index included, try to pull the information about it thisRange = null; details = null; if (index >= 1) { thisRange = UI_ApplicationCache_Gateway.IP_Restrictions[index]; if (thisRange != null) { details = SobekCM_Database.Get_IP_Restriction_Range_Details(thisRange.RangeID, RequestSpecificValues.Tracer); } } readOnlyMode = true; if (((RequestSpecificValues.Current_User.Is_System_Admin) && (!UI_ApplicationCache_Gateway.Settings.Servers.isHosted)) || (RequestSpecificValues.Current_User.Is_Host_Admin)) { readOnlyMode = false; } if ((RequestSpecificValues.Current_Mode.isPostBack) && (RequestSpecificValues.Current_User.Is_System_Admin)) { if (readOnlyMode) { return; } // Get a reference to this form NameValueCollection form = HttpContext.Current.Request.Form; string action = form["action"].Trim(); if (action == "new") { // Pull the main values entered_title = form["new_admin_title"].Trim(); entered_notes = form["new_admin_notes"].Trim(); entered_message = form["new_admin_message"].Trim(); if ((entered_title.Length == 0) || (entered_message.Length == 0)) { actionMessage = "Both title and message are required fields"; } else { if (SobekCM_Database.Edit_IP_Range(-1, entered_title, entered_notes, entered_message, RequestSpecificValues.Tracer)) { actionMessage = "Saved new IP range '" + entered_title + "'"; entered_title = String.Empty; entered_notes = String.Empty; entered_message = String.Empty; // Need to recalcualte the IP range membership for the current user HttpContext.Current.Session["IP_Range_Membership"] = null; } else { actionMessage = "Error saving new IP range '" + entered_title + "'"; } } } else if (action == "delete") { int id_to_delete = Int32.Parse(form["admin_ip_delete"]); string delete_title = UI_ApplicationCache_Gateway.IP_Restrictions[id_to_delete].Title; if (SobekCM_Database.Delete_IP_Range(id_to_delete, RequestSpecificValues.Tracer)) { actionMessage = "Deleted IP range '" + delete_title + "'"; // Need to recalcualte the IP range membership for the current user HttpContext.Current.Session["IP_Range_Membership"] = null; } else { actionMessage = "Error deleting new IP range '" + delete_title + "'"; } } else if ((details != null) && (thisRange != null)) { try { // Pull the main values string title = form["admin_title"].Trim(); string notes = form["admin_notes"].Trim(); string message = form["admin_message"].Trim(); if (title.Length == 0) { title = thisRange.Title; } // Edit the main values in the database SobekCM_Database.Edit_IP_Range(thisRange.RangeID, title, notes, message, RequestSpecificValues.Tracer); thisRange.Title = title; thisRange.Notes = notes; thisRange.Item_Restricted_Statement = message; // Now check each individual IP address range string[] getKeys = form.AllKeys; int single_ip_index = 0; foreach (string thisKey in getKeys) { // Is this for a new ip address? if (thisKey.IndexOf("admin_ipstart_") == 0) { // Get the basic information for this single ip address string ip_index = thisKey.Replace("admin_ipstart_", ""); string thisIpStart = form["admin_ipstart_" + ip_index].Trim(); string thisIpEnd = form["admin_ipend_" + ip_index].Trim(); string thisIpNote = form["admin_iplabel_" + ip_index].Trim(); // Does this match an existing IP range? if ((ip_index.IndexOf("new") < 0) && (single_ip_index < details.Tables[1].Rows.Count)) { // Get the pre-existing IP row DataRow ipRow = details.Tables[1].Rows[single_ip_index]; int singleIpId = Convert.ToInt32(ipRow[0]); if (thisIpStart.Length == 0) { SobekCM_Database.Delete_Single_IP(singleIpId, RequestSpecificValues.Tracer); } else { // Is this the same? if ((thisIpStart != ipRow[1].ToString().Trim()) || (thisIpEnd != ipRow[2].ToString().Trim()) || (thisIpNote != ipRow[3].ToString().Trim())) { int edit_point_count = thisIpStart.Count(ThisChar => ThisChar == '.'); if (edit_point_count == 3) { SobekCM_Database.Edit_Single_IP(singleIpId, thisRange.RangeID, thisIpStart, thisIpEnd, thisIpNote, RequestSpecificValues.Tracer); } } } // Be ready to look at the next pre-existing IP range single_ip_index++; } else { // Just add this as a new single ip address if (thisIpStart.Length > 0) { int add_point_count = thisIpStart.Count(ThisChar => ThisChar == '.'); if (add_point_count == 3) { SobekCM_Database.Edit_Single_IP(-1, thisRange.RangeID, thisIpStart, thisIpEnd, thisIpNote, RequestSpecificValues.Tracer); } } } } } // Need to recalcualte the IP range membership for the current user HttpContext.Current.Session["IP_Range_Membership"] = null; } catch (Exception) { actionMessage = "Error saving IP range"; } } // Repopulate the restriction table DataTable ipRestrictionTbl = SobekCM_Database.Get_IP_Restriction_Ranges(RequestSpecificValues.Tracer); if (ipRestrictionTbl != null) { UI_ApplicationCache_Gateway.IP_Restrictions.Populate_IP_Ranges(ipRestrictionTbl); } // Forward back to the main form if (String.IsNullOrEmpty(actionMessage)) { RequestSpecificValues.Current_Mode.My_Sobek_SubMode = String.Empty; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } } }
/// <summary> Constructor for a new instance of the Builder_Folder_Mgmt_AdminViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> public Builder_Folder_Mgmt_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { // Verify this user can edit this bool allowEdit = (((!UI_ApplicationCache_Gateway.Settings.Servers.isHosted) && (RequestSpecificValues.Current_User.Is_System_Admin)) || (RequestSpecificValues.Current_User.Is_Host_Admin)); if (!allowEdit) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // Is there a folder specified? folderId = -1; if ((RequestSpecificValues.Current_Mode.Remaining_Url_Segments != null) && (RequestSpecificValues.Current_Mode.Remaining_Url_Segments.Length > 0)) { if (String.Compare(RequestSpecificValues.Current_Mode.Remaining_Url_Segments[0], "new", StringComparison.OrdinalIgnoreCase) != 0) { if (!Int32.TryParse(RequestSpecificValues.Current_Mode.Remaining_Url_Segments[0], out folderId)) { folderId = -1; } } } // Handle any post backs saved = false; if (RequestSpecificValues.Current_Mode.isPostBack) { try { // Pull the standard values from the form NameValueCollection form = HttpContext.Current.Request.Form; string action_value = form["admin_builder_folder_action"]; // Get the entered values folderName = form["admin_folder_name"]; failuresFolder = form["admin_folder_error"]; inboundFolder = form["admin_folder_network"]; processingFolder = form["admin_folder_processing"]; performChecksum = (form["admin_folder_checksum"] != null); archiveTiffs = (form["admin_folder_archive_tiff"] != null); archiveAllFiles = (form["admin_folder_archive_all"] != null); allowDeletes = (form["admin_folder_allow_delete"] != null); allowFoldersNoMetadata = (form["admin_folder_no_metadata"] != null); allowMetadataUpdates = (form["admin_folder_allow_updates"] != null); // Get the hidden values bibIdRestrictions = form["admin_builder_folder_restrictions"]; moduleSetId = Int32.Parse(form["admin_builder_folder_modulesetid"]); // The folders should always end with a slash if ((!String.IsNullOrWhiteSpace(failuresFolder)) && (failuresFolder.Length > 2) && (failuresFolder[failuresFolder.Length - 1] != '\\')) { failuresFolder = failuresFolder + "\\"; } if ((!String.IsNullOrWhiteSpace(inboundFolder)) && (inboundFolder.Length > 2) && (inboundFolder[inboundFolder.Length - 1] != '\\')) { inboundFolder = inboundFolder + "\\"; } if ((!String.IsNullOrWhiteSpace(processingFolder)) && (processingFolder.Length > 2) && (processingFolder[processingFolder.Length - 1] != '\\')) { processingFolder = processingFolder + "\\"; } // Switch, depending on the request if (!String.IsNullOrEmpty(action_value)) { // Was this a CANCEL? if (action_value == "cancel") { // Determine URL string returnUrl = RequestSpecificValues.Current_Mode.Base_URL + "l/admin/settings/builder/folders"; RequestSpecificValues.Current_Mode.Request_Completed = true; HttpContext.Current.Response.Redirect(returnUrl, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); return; } // Was this a DELETE/ if (action_value == "delete") { // Try to delete this folder bool result = SobekCM_Database.Builder_Folder_Delete(folderId, RequestSpecificValues.Tracer); if (!result) { actionMessage = "Unknown error encountered while trying to delete this folder"; } else { // Clear settings to be pulled again HttpContext.Current.Session["Admin_Settigs"] = null; // Assign this to be used by the system UI_ApplicationCache_Gateway.ResetSettings(); // Return to the folder list string returnUrl = RequestSpecificValues.Current_Mode.Base_URL + "l/admin/settings/builder/folders"; RequestSpecificValues.Current_Mode.Request_Completed = true; HttpContext.Current.Response.Redirect(returnUrl, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); return; } } // Was this a SAVE? if (action_value == "save") { // Perform some validations List <string> errors = new List <string>(); if (String.IsNullOrWhiteSpace(folderName)) { errors.Add("DESCRIPTIVE NAME is required and missing"); } if (String.IsNullOrWhiteSpace(failuresFolder)) { errors.Add("FAILURES FOLDER is required and missing"); } if (String.IsNullOrWhiteSpace(inboundFolder)) { errors.Add("INBOUND FOLDER is required and missing"); } if (String.IsNullOrWhiteSpace(processingFolder)) { errors.Add("PROCESSING FOLDER is required and missing"); } // If there were error, prepare the error message and don't save if (errors.Count > 0) { actionMessage = "ERROR: Some required fields are missing:<br /><br />"; foreach (string thisError in errors) { actionMessage = actionMessage + " " + thisError + "<br />"; } } else { // Try to save this folder bool result = SobekCM_Database.Builder_Folder_Edit(folderId, folderName, inboundFolder, failuresFolder, processingFolder, performChecksum, archiveTiffs, archiveAllFiles, allowDeletes, allowFoldersNoMetadata, bibIdRestrictions, moduleSetId, RequestSpecificValues.Tracer); if (!result) { actionMessage = "Unknown error encountered while saving folder to the database"; } else { // Successfully saved saved = true; actionMessage = "Successfully saved builder folder changes."; // Clear settings to be pulled again HttpContext.Current.Session["Admin_Settigs"] = null; // Assign this to be used by the system UI_ApplicationCache_Gateway.ResetSettings(); // Also, look to see if a warning might be suitable List <string> warnings = new List <string>(); try { if (!Directory.Exists(failuresFolder)) { warnings.Add("Can't verify existence of the FAILURES FOLDER"); } if (!Directory.Exists(inboundFolder)) { warnings.Add("Can't verify existence of the INBOUND FOLDER"); } if (!Directory.Exists(processingFolder)) { warnings.Add("Can't verify existence of the PROCESSING FOLDER"); } } catch (Exception) { warnings.Clear(); warnings.Add("Exception caught while trying to verify folders."); } // Add warnings if (warnings.Count == 3) { // i.e., none of the folders could be verified actionMessage = actionMessage + "<br /><br />WARNING: Unable to verify existence of any of the folders. This may be normal since the account under which the web runs does not necessarily need access to the builder folders."; } else if (warnings.Count > 0) { actionMessage = actionMessage + "<br /><br />WARNING: Unable to verify existence of some of the folders:<br /><br />"; foreach (string thisWarning in warnings) { actionMessage = actionMessage + " " + thisWarning + "<br />"; } } } } } } } catch { } } else // NOT A POST BACK { // Configure the values folderName = String.Empty; failuresFolder = String.Empty; inboundFolder = String.Empty; processingFolder = String.Empty; performChecksum = false; archiveTiffs = false; archiveAllFiles = false; allowDeletes = true; allowFoldersNoMetadata = true; bibIdRestrictions = String.Empty; moduleSetId = 10; // Is there a folder specified? if (folderId > 0) { // Try to get this source folder Builder_Source_Folder sourceFolder = SobekEngineClient.Builder.Get_Builder_Folder(folderId, RequestSpecificValues.Tracer); if (sourceFolder != null) { // Set the values from the existing source folder folderName = sourceFolder.Folder_Name; failuresFolder = sourceFolder.Failures_Folder; inboundFolder = sourceFolder.Inbound_Folder; processingFolder = sourceFolder.Processing_Folder; performChecksum = sourceFolder.Perform_Checksum; archiveTiffs = sourceFolder.Archive_TIFFs; archiveAllFiles = sourceFolder.Archive_All_Files; allowDeletes = sourceFolder.Allow_Deletes; allowFoldersNoMetadata = sourceFolder.Allow_Folders_No_Metadata; allowMetadataUpdates = sourceFolder.Allow_Metadata_Updates; bibIdRestrictions = sourceFolder.BibID_Roots_Restrictions; moduleSetId = sourceFolder.Builder_Module_Set.SetID; } else { folderId = -1; } } } }
/// <summary> Constructor for a new instance of the Private_Items_AggregationViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <param name="ViewBag"> Aggregation-specific request information, such as aggregation object and any browse object requested </param> public Private_Items_AggregationViewer(RequestCache RequestSpecificValues, AggregationViewBag ViewBag) : base(RequestSpecificValues, ViewBag) { // Ensure user has some permissions on this aggregation, or is a power/internal user or admin before showing // them this list if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn)) { RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // Does this user have permissions on this itgem if (RequestSpecificValues.Current_User.PermissionedAggregations != null) { // Do they have some special permissions against this aggregation? bool special_permissions_found = false; foreach (User_Permissioned_Aggregation permissions in RequestSpecificValues.Current_User.PermissionedAggregations) { if (String.Compare(permissions.Code, ViewBag.Hierarchy_Object.Code, StringComparison.OrdinalIgnoreCase) == 0) { if ((permissions.CanChangeVisibility) || (permissions.CanDelete) || (permissions.CanEditBehaviors) || (permissions.CanEditItems) || (permissions.CanEditMetadata) || (permissions.CanPerformQc) || (permissions.CanUploadFiles) || (permissions.IsAdmin) || (permissions.IsCurator)) { special_permissions_found = true; break; } } } // Are they a portal/system admin or power user? if ((!special_permissions_found) && ((RequestSpecificValues.Current_User.Is_Internal_User) || (RequestSpecificValues.Current_User.Is_Portal_Admin) || (RequestSpecificValues.Current_User.Is_System_Admin))) { special_permissions_found = true; } // If no permissions, forward them back if (!special_permissions_found) { RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } } else { // Are they a portal/system admin or power user? if ((!RequestSpecificValues.Current_User.Is_Internal_User) && (!RequestSpecificValues.Current_User.Is_Portal_Admin) && (!RequestSpecificValues.Current_User.Is_System_Admin)) { RequestSpecificValues.Current_Mode.Aggregation_Type = Aggregation_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } } // Get the list of private items int current_sort = RequestSpecificValues.Current_Mode.Sort.HasValue ? RequestSpecificValues.Current_Mode.Sort.Value : 0; int current_page = RequestSpecificValues.Current_Mode.Page.HasValue ? RequestSpecificValues.Current_Mode.Page.Value : 1; privateItems = Engine_Database.Tracking_Get_Aggregation_Private_Items(ViewBag.Hierarchy_Object.Code, (int)RESULTS_PER_PAGE, current_page, current_sort, RequestSpecificValues.Tracer); }
/// <summary> Constructor for a new instance of the Skins_AdminViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <remarks> Postback from handling an edit or new html skin is handled here in the constructor </remarks> public Skins_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("Skins_AdminViewer.Constructor", String.Empty); // Set action message to nothing to start actionMessage = String.Empty; // If the RequestSpecificValues.Current_User cannot edit this, go back if ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin)) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // If this is a postback, handle any events first if (RequestSpecificValues.Current_Mode.isPostBack) { try { // Pull the standard values NameValueCollection form = HttpContext.Current.Request.Form; string reset_value = form["admin_interface_reset"].ToLower(); string save_value = form["admin_interface_tosave"].ToUpper().Trim(); string delete_value = form["admin_interface_delete"].ToUpper().Trim(); string new_interface_code = form["admin_interface_code"].ToUpper().Trim(); // Was this a reset request? if (reset_value.Length > 0) { RequestSpecificValues.Tracer.Add_Trace("Skins_AdminViewer.Constructor", "Reset html skin '" + reset_value + "'"); int values_cleared = CachedDataManager.WebSkins.Remove_Skin(reset_value, RequestSpecificValues.Tracer); if (values_cleared == 0) { actionMessage = "Html skin <i>" + reset_value.ToUpper() + "</i> was not in the application cache"; } else { actionMessage = "Removed " + values_cleared + " values from the cache for <i>" + reset_value.ToUpper() + "</i>"; } } else if (delete_value.Length > 0) { if (RequestSpecificValues.Current_User.Is_System_Admin) { RequestSpecificValues.Tracer.Add_Trace("Skins_AdminViewer.Constructor", "Delete skin '" + delete_value + "' from the database"); // Delete from the database if (SobekCM_Database.Delete_Web_Skin(delete_value, false, RequestSpecificValues.Tracer)) { // Set the deleted wordmark message actionMessage = "Deleted web skin <i>" + delete_value + "</i>"; // Remove this web skin from the collection Web_Skin_Utilities.Populate_Default_Skins(UI_ApplicationCache_Gateway.Web_Skin_Collection, RequestSpecificValues.Tracer); // If this was your current web skin, forward if (String.Compare(delete_value, RequestSpecificValues.HTML_Skin.Skin_Code, StringComparison.InvariantCultureIgnoreCase) == 0) { RequestSpecificValues.Current_Mode.Skin_In_URL = false; RequestSpecificValues.Current_Mode.Skin = null; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } } else { // Report the error if (SobekCM_Database.Last_Exception == null) { actionMessage = "Error: Unable to delete web skin <i>" + delete_value + "</i> since it is linked to an item, aggregation, or portal"; } else { actionMessage = "Unknown error while deleting web skin <i>" + delete_value + "</i>"; } } } } else { // Or.. was this a save request if (save_value.Length > 0) { RequestSpecificValues.Tracer.Add_Trace("Skins_AdminViewer.Constructor", "Save html skin '" + save_value + "'"); bool override_banner = false; bool override_header = false; bool suppress_top_nav = false; bool copycurrent = false; object temp_object; // Was this to save a new interface (from the main page) or edit an existing (from the popup form)? if (save_value == new_interface_code) { string new_base_code = form["admin_interface_basecode"].ToUpper().Trim(); string new_banner_link = form["admin_interface_link"].Trim(); string new_notes = form["admin_interface_notes"].Trim(); temp_object = form["admin_interface_banner_override"]; if (temp_object != null) { override_banner = true; } temp_object = form["admin_interface_top_nav"]; if (temp_object != null) { suppress_top_nav = true; } temp_object = form["admin_interface_copycurrent"]; if (temp_object != null) { copycurrent = true; } // Only real validation needed is that this is a new wek skin name and is alphanumeric bool result = save_value.All(C => Char.IsLetterOrDigit(C) || C == '_'); bool existing_already = UI_ApplicationCache_Gateway.Web_Skin_Collection.Ordered_Skin_Codes.Any(ThisSkinCode => String.Equals(ThisSkinCode, save_value, StringComparison.CurrentCultureIgnoreCase)); if ((!result) || (existing_already)) { actionMessage = !result ? "ERROR: New web skin code must be only letters and numbers" : "ERROR: New web skin code already exists!"; } else { // Save this new interface if (SobekCM_Database.Save_Web_Skin(save_value, new_base_code, override_banner, true, new_banner_link, new_notes, suppress_top_nav, RequestSpecificValues.Tracer)) { // Ensure a folder exists for this, otherwise create one try { string folder = UI_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + "skins/" + save_value.ToLower(); if (!Directory.Exists(folder)) { // Create this directory and the necessary subdirectories Directory.CreateDirectory(folder); // Create a default stylesheet StreamWriter writer = new StreamWriter(folder + "\\" + save_value.ToLower() + ".css"); writer.WriteLine("/* Skin-specific stylesheet used to override values from the base stylesheets */"); writer.WriteLine(); writer.WriteLine(); writer.Flush(); writer.Close(); // Create the html subdirectory Directory.CreateDirectory(folder + "/html"); // Do the rest differently depending on whether we should copy the current files if (!copycurrent) { // Write the default header file writer = new StreamWriter(folder + "\\html\\header.html"); writer.WriteLine("<div id=\"container-inner\">"); writer.WriteLine(); writer.WriteLine("<!-- Add the standard header buttons -->"); writer.WriteLine("<div style=\"width: 100%; background-color: #eeeeee; color: Black; height:30px;\">"); writer.WriteLine("<%BREADCRUMBS%>"); writer.WriteLine("<div style=\"float: right\"><%MYSOBEK%></div>"); writer.WriteLine("</div>"); writer.WriteLine(); writer.WriteLine("<%BANNER%>"); writer.WriteLine(); writer.WriteLine("<div id=\"pagecontainer\">"); writer.WriteLine(); writer.WriteLine("<!-- Blankets out the rest of the web form when a pop-up form is envoked -->"); writer.WriteLine("<div id=\"blanket_outer\" style=\"display:none;\"></div>"); writer.Flush(); writer.Close(); // Write the default header_item file writer = new StreamWriter(folder + "/html/header_item.html"); writer.WriteLine("<!-- Blankets out the rest of the web form when a pop-up form is envoked -->"); writer.WriteLine("<div id=\"blanket_outer\" style=\"display:none;\"></div>"); writer.WriteLine(); writer.WriteLine("<!-- Add the standard header buttons -->"); writer.WriteLine("<div style=\"width: 100%; background-color: #eeeeee; color: Black; height:30px;\">"); writer.WriteLine("<%BREADCRUMBS%>"); writer.WriteLine("<div style=\"float: right\"><%MYSOBEK%></div>"); writer.WriteLine("</div>"); writer.WriteLine(); writer.WriteLine("<%BANNER%>"); writer.Flush(); writer.Close(); // Write the default footer file writer = new StreamWriter(folder + "/html/footer.html"); writer.WriteLine("</div> <!-- END PAGE CONTAINER DIV -->"); writer.WriteLine(); writer.WriteLine("<!-- Add most the standard footer buttons -->"); writer.WriteLine("<center>"); writer.WriteLine("<a href=\"<%BASEURL%>contact<%?URLOPTS%>\">Contact Us</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>preferences<%?URLOPTS%>\">Preferences</a> | "); writer.WriteLine("<a href=\"http://ufdc.ufl.edu/sobekcm\">Technical Aspects</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>stats<%?URLOPTS%>\">Statistics</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>internal<%?URLOPTS%>\">Internal</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>admin<%?URLOPTS%>\">Admin</a>"); writer.WriteLine("</center>"); writer.WriteLine("<br />"); writer.WriteLine("<br />"); writer.WriteLine("<span style=\"color: Gray; font-size: 0.8em;\">"); writer.WriteLine("To edit this footer or header, edit header.html or footer.html at: " + folder + "\\html\\ <br />"); writer.WriteLine("</span>"); writer.WriteLine(); writer.WriteLine("</div> <!-- END CONTAINER INNER -->"); writer.Flush(); writer.Close(); // Write the default footer item file writer = new StreamWriter(folder + "/html/footer_item.html"); writer.WriteLine("<!-- Add most the standard footer buttons -->"); writer.WriteLine("<center>"); writer.WriteLine("<a href=\"<%BASEURL%>contact<%?URLOPTS%>\">Contact Us</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>preferences<%?URLOPTS%>\">Preferences</a> | "); writer.WriteLine("<a href=\"http://ufdc.ufl.edu/sobekcm\">Technical Aspects</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>stats<%?URLOPTS%>\">Statistics</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>internal<%?URLOPTS%>\">Internal</a> | "); writer.WriteLine("<a href=\"<%BASEURL%>admin<%?URLOPTS%>\">Admin</a>"); writer.WriteLine("</center>"); writer.WriteLine("<br />"); writer.WriteLine("<br />"); writer.WriteLine("<span style=\"color: Gray; font-size: 0.8em;\">"); writer.WriteLine("To edit this footer or header, edit header.html or footer.html at: " + folder + "\\html\\ <br />"); writer.WriteLine("</span>"); writer.Flush(); writer.Close(); } else { // Copy the web skin information over? string current_web_skin = RequestSpecificValues.Current_Mode.Skin; string current_web_folder = UI_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + "skins/" + current_web_skin; copy_entire_folder(current_web_folder, folder); //if (File.Exists(current_web_folder + "\\" + current_web_skin + ".css")) //{ // File.Copy(current_web_folder + "\\" + current_web_skin + ".css", folder + "\\" + new_interface_code + ".css", true ); //} //if (File.Exists(current_web_folder + "\\html\\header.html")) //{ // File.Copy(current_web_folder + "\\html\\header.html", folder + "\\html\\header.html"); //} //if (File.Exists(current_web_folder + "\\html\\header_item.html")) //{ // File.Copy(current_web_folder + "\\html\\header_item.html", folder + "\\html\\header_item.html"); //} //if (File.Exists(current_web_folder + "\\html\\footer.html")) //{ // File.Copy(current_web_folder + "\\html\\footer.html", folder + "\\html\\footer.html"); //} //if (File.Exists(current_web_folder + "\\html\\footer_item.html")) //{ // File.Copy(current_web_folder + "\\html\\footer_item.html", folder + "\\html\\footer_item.html"); //} if (File.Exists(folder + "\\" + current_web_skin + ".css")) { if (File.Exists(folder + "\\" + new_interface_code + ".css")) { File.Delete(folder + "\\" + new_interface_code + ".css"); } File.Move(folder + "\\" + current_web_skin + ".css", folder + "\\" + new_interface_code + ".css"); } } // Irregardless of the RequestSpecificValues.Current_User's choice on whether to copy the current skin, if there is NO base skin // provided and the folder does not exist, then we'll copy over the base skin type of stuff, such // as buttons, tabs, etc... if (new_base_code.Length == 0) { // What is the current base skin folder then? string base_skin_folder = UI_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + "skins/" + RequestSpecificValues.Current_Mode.Base_Skin_Or_Skin; copy_entire_folder(base_skin_folder + "/buttons", folder + "/buttons"); copy_entire_folder(base_skin_folder + "/tabs", folder + "/tabs"); } } } catch { actionMessage = "Error creating some of the files for the new web skin"; } // Reload the list of all skins from the database, to include this new skin lock (UI_ApplicationCache_Gateway.Web_Skin_Collection) { Web_Skin_Utilities.Populate_Default_Skins(UI_ApplicationCache_Gateway.Web_Skin_Collection, RequestSpecificValues.Tracer); } if (String.IsNullOrEmpty(actionMessage)) { actionMessage = "Saved new html skin <i>" + save_value + "</i>"; } } else { actionMessage = "Unable to save new html skin <i>" + save_value + "</i>"; } // Try to create the directory try { if (!Directory.Exists(UI_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + "skins\\" + save_value)) { Directory.CreateDirectory(UI_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + "skins\\" + save_value); } if (!Directory.Exists(UI_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + "skins\\" + save_value + "\\html")) { Directory.CreateDirectory(UI_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + "skins\\" + save_value + "\\html"); } if (new_base_code.Length == 0) { if (!Directory.Exists(UI_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + "skins\\" + save_value + "\\buttons")) { Directory.CreateDirectory(UI_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + "skins\\" + save_value + "\\buttons"); } if (!Directory.Exists(UI_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + "skins\\" + save_value + "\\tabs")) { Directory.CreateDirectory(UI_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + "skins\\" + save_value + "\\tabs"); } if (!Directory.Exists(UI_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + "skins\\" + save_value + "\\zoom_controls")) { Directory.CreateDirectory(UI_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + "skins\\" + save_value + "\\zoom_controls"); } } } catch { actionMessage = "Error creating all the necessary folders"; } } } else { string edit_base_code = form["form_interface_basecode"].ToUpper().Trim(); string edit_banner_link = form["form_interface_link"].Trim(); string edit_notes = form["form_interface_notes"].Trim(); temp_object = form["form_interface_banner_override"]; if (temp_object != null) { override_banner = true; } temp_object = form["form_interface_header_override"]; if (temp_object != null) { override_header = true; } temp_object = form["form_interface_top_nav"]; if (temp_object != null) { suppress_top_nav = true; } // Save this existing interface if (SobekCM_Database.Save_Web_Skin(save_value, edit_base_code, override_banner, override_header, edit_banner_link, edit_notes, suppress_top_nav, RequestSpecificValues.Tracer)) { lock (UI_ApplicationCache_Gateway.Web_Skin_Collection) { Web_Skin_Utilities.Populate_Default_Skins(UI_ApplicationCache_Gateway.Web_Skin_Collection, RequestSpecificValues.Tracer); } CachedDataManager.WebSkins.Remove_Skin(save_value, RequestSpecificValues.Tracer); actionMessage = "Edited existing html skin <i>" + save_value + "</i>"; } else { actionMessage = "Unable to edit existing html skin <i>" + save_value + "</i>"; } } } } } catch (Exception) { actionMessage = "Unknown error caught while handing your request."; } } }
public Import_Spreadsheet_MySobekViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("Import_Spreadsheet_MySobekViewer.Constructor", String.Empty); // If the RequestSpecificValues.Current_User cannot submit items, go back //if (!RequestSpecificValues.Current_User.Can_Submit) //{ // RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; // UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); // return; //} // Create a new GUID for this task, or get from the session state string guid = HttpContext.Current.Session["Import_Data_Current_GUID"] as string; if (String.IsNullOrEmpty(guid)) { guid = Guid.NewGuid().ToString(); HttpContext.Current.Session.Add("Import_Data_Current_GUID", guid); } // Determine the in process directory for this if (RequestSpecificValues.Current_User.ShibbID.Trim().Length > 0) { taskUrl = RequestSpecificValues.Current_Mode.Base_URL + "mySobek/InProcess/" + RequestSpecificValues.Current_User.ShibbID + "/task/" + guid; taskDirectory = Path.Combine(UI_ApplicationCache_Gateway.Settings.Servers.In_Process_Submission_Location, RequestSpecificValues.Current_User.ShibbID, "task", guid); } else { taskUrl = RequestSpecificValues.Current_Mode.Base_URL + "mySobek/InProcess/" + RequestSpecificValues.Current_User.UserName.Replace(".", "").Replace("@", "") + "/task/" + guid; taskDirectory = Path.Combine(UI_ApplicationCache_Gateway.Settings.Servers.In_Process_Submission_Location, RequestSpecificValues.Current_User.UserName.Replace(".", "").Replace("@", ""), "task", guid); } // Try to determine the current page page = 1; int.TryParse(RequestSpecificValues.Current_Mode.My_Sobek_SubMode, out page); if (page < 1) { page = 1; } // Is there a data file here? string extension = null; if (Directory.Exists(taskDirectory)) { string[] source_file = SobekCM_File_Utilities.GetFiles(taskDirectory, "*.xls|*.xlsx|*.csv|*.mrc"); if (source_file.Length > 0) { file_name = Path.GetFileName(source_file[0]); extension = Path.GetExtension(source_file[0]); } } // Determine file type if ((!String.IsNullOrEmpty(file_name)) && (!String.IsNullOrEmpty(extension))) { switch (extension.ToUpper()) { case ".XLS": case ".XLSX": file_type = Import_File_Type_Enum.Excel; break; case ".CSV": case ".TXT": file_type = Import_File_Type_Enum.CSV; break; case ".MRC": file_type = Import_File_Type_Enum.Marc21; break; case ".XML": file_type = Import_File_Type_Enum.MarcXML; break; } } else { file_type = Import_File_Type_Enum.None; } // Handle postback for changing the CompleteTemplate or project if (RequestSpecificValues.Current_Mode.isPostBack) { string action1 = HttpContext.Current.Request.Form["action"]; if (action1 == "cancel") { if (Directory.Exists(taskDirectory)) { string[] allFiles = Directory.GetFiles(taskDirectory); foreach (string thisFile in allFiles) { File.Delete(thisFile); } Directory.Delete(taskDirectory); } HttpContext.Current.Session["Import_Data_Current_GUID"] = null; HttpContext.Current.Session["Import_Data_Current_Worksheet"] = null; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } if (action1 == "delete") { if (Directory.Exists(taskDirectory)) { string file = Path.Combine(taskDirectory, file_name); if (File.Exists(file)) { File.Delete(file); } } page = 1; file_name = String.Empty; file_type = Import_File_Type_Enum.None; HttpContext.Current.Session["Import_Data_Current_Worksheet"] = null; } } }
/// <summary> Constructor for a new instance of the Thematic_Headings_AdminViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <remarks> Postback from handling an edit or new thematic heading is handled here in the constructor </remarks> public Thematic_Headings_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("Thematic_Headings_AdminViewer.Constructor", String.Empty); // Set action message to nothing to start actionMessage = String.Empty; // If the RequestSpecificValues.Current_User cannot edit this, go back if ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin)) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // Handle any post backs if (RequestSpecificValues.Current_Mode.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 + UI_ApplicationCache_Gateway.Thematic_Headings.TakeWhile(ThisHeading => ThisHeading.ID != id).Count(); if (Engine_Database.Edit_Thematic_Heading(id, order, new_name, RequestSpecificValues.Tracer) < 1) { actionMessage = "Unable to edit existing thematic heading"; } else { // For thread safety, lock the thematic headings list Engine_ApplicationCache_Gateway.RefreshThematicHeadings(); actionMessage = "Thematic heading edits saved"; } } break; case "delete": int thematicDeleteId = Convert.ToInt32(save_value); if (!Engine_Database.Delete_Thematic_Heading(thematicDeleteId, RequestSpecificValues.Tracer)) { // Set action message actionMessage = "Unable to delete existing thematic heading"; } else { // For thread safety, lock the thematic headings list lock (UI_ApplicationCache_Gateway.Thematic_Headings) { // Remove this thematic heading from the list int i = 0; while (i < UI_ApplicationCache_Gateway.Thematic_Headings.Count) { if (UI_ApplicationCache_Gateway.Thematic_Headings[i].ID == thematicDeleteId) { UI_ApplicationCache_Gateway.Thematic_Headings.RemoveAt(i); } else { i++; } } } // Set action message actionMessage = "Thematic heading deleted"; } break; case "new": int new_order = UI_ApplicationCache_Gateway.Thematic_Headings.Count + 1; int newid = Engine_Database.Edit_Thematic_Heading(-1, new_order, save_value, RequestSpecificValues.Tracer); if (newid < 1) { actionMessage = "Unable to save new thematic heading"; } else { // For thread safety, lock the thematic headings list lock (UI_ApplicationCache_Gateway.Thematic_Headings) { // Repopulate the thematic headings list Engine_Database.Populate_Thematic_Headings(UI_ApplicationCache_Gateway.Thematic_Headings, RequestSpecificValues.Tracer); } // Add this blank thematic heading to the code manager UI_ApplicationCache_Gateway.Aggregations.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 = UI_ApplicationCache_Gateway.Thematic_Headings[moveup_order - 1]; if (themeHeading.ID == moveup_id) { // For thread safety, lock the thematic headings list lock (UI_ApplicationCache_Gateway.Thematic_Headings) { // Move this thematic heading up UI_ApplicationCache_Gateway.Thematic_Headings.Remove(themeHeading); UI_ApplicationCache_Gateway.Thematic_Headings.Insert(moveup_order - 2, themeHeading); int current_order = 1; foreach (Thematic_Heading thisTheme in UI_ApplicationCache_Gateway.Thematic_Headings) { Engine_Database.Edit_Thematic_Heading(thisTheme.ID, current_order, thisTheme.Text, RequestSpecificValues.Tracer); current_order++; } // Repopulate the thematic headings list Engine_Database.Populate_Thematic_Headings(UI_ApplicationCache_Gateway.Thematic_Headings, RequestSpecificValues.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 < UI_ApplicationCache_Gateway.Thematic_Headings.Count) { Thematic_Heading themeHeading = UI_ApplicationCache_Gateway.Thematic_Headings[movedown_order - 1]; if (themeHeading.ID == movedown_id) { // For thread safety, lock the thematic headings list lock (UI_ApplicationCache_Gateway.Thematic_Headings) { // Move this thematic heading down UI_ApplicationCache_Gateway.Thematic_Headings.Remove(themeHeading); UI_ApplicationCache_Gateway.Thematic_Headings.Insert(movedown_order, themeHeading); int current_order = 1; foreach (Thematic_Heading thisTheme in UI_ApplicationCache_Gateway.Thematic_Headings) { Engine_Database.Edit_Thematic_Heading(thisTheme.ID, current_order, thisTheme.Text, RequestSpecificValues.Tracer); current_order++; } // Repopulate the thematic headings list Engine_Database.Populate_Thematic_Headings(UI_ApplicationCache_Gateway.Thematic_Headings, RequestSpecificValues.Tracer); } } } break; } } } catch (Exception) { actionMessage = "Unknown error caught while handling your reqeust"; } } }
/// <summary> Constructor for a new instance of the Group_Add_Volume_MySobekViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> public Group_Add_Volume_MySobekViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", String.Empty); // If no user then that is an error if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn)) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation; RequestSpecificValues.Current_Mode.Aggregation = String.Empty; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // Ensure BibID provided RequestSpecificValues.Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Validate provided bibid"); if (String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.BibID)) { RequestSpecificValues.Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "BibID was not provided!"); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error; RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : BibID missing in item group metadata edit request"; return; } RequestSpecificValues.Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Try to pull this sobek complete item group"); currentItem = SobekEngineClient.Items.Get_Sobek_Item_Group(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Tracer); if (currentItem == null) { RequestSpecificValues.Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Unable to build complete item group"); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error; RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : Unable to build complete item"; return; } // Pull the list of items tied to this group - Get the list of other volumes RequestSpecificValues.Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Get the list of items under " + RequestSpecificValues.Current_Mode.BibID); try { allVolumes = SobekEngineClient.Items.Get_Multiple_Volumes(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Tracer); } catch (Exception ee) { RequestSpecificValues.Tracer.Add_Trace("Tracking_ItemViewer.Constructor", "Unable to pull volumes under " + RequestSpecificValues.Current_Mode.BibID); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error; RequestSpecificValues.Current_Mode.Error_Message = "Internal Error : Unable to pull volumes under " + RequestSpecificValues.Current_Mode.BibID; return; } // 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 (!RequestSpecificValues.Current_User.Can_Edit_This_Item(currentItem.BibID, currentItem.Bib_Info.SobekCM_Type_String, currentItem.Bib_Info.Source.Code, currentItem.Bib_Info.HoldingCode, currentItem.Behaviors.Aggregation_Code_List)) { RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // Determine the default CompleteTemplate code string template_code = "addvolume"; if (!RequestSpecificValues.Current_User.Include_Tracking_In_Standard_Forms) { template_code = "addvolume_notracking"; } // Load this CompleteTemplate completeTemplate = Template_MemoryMgmt_Utility.Retrieve_Template(template_code, RequestSpecificValues.Tracer); if (completeTemplate != null) { RequestSpecificValues.Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Found CompleteTemplate in cache"); } else { RequestSpecificValues.Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Reading CompleteTemplate file"); // Look in the user-defined templates portion first string user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\user\\standard\\" + template_code + ".xml"; if (!File.Exists(user_template)) { user_template = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "templates\\default\\standard\\" + template_code + ".xml"; } // Read this template Template_XML_Reader reader = new Template_XML_Reader(); completeTemplate = new CompleteTemplate(); reader.Read_XML(user_template, completeTemplate, true); // Save this into the cache Template_MemoryMgmt_Utility.Store_Template(template_code, completeTemplate, RequestSpecificValues.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") { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } 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 Tuple <SobekCM_Item, SobekCM_Item_Error> itemAndError = SobekCM_Item_Factory.Get_Item(RequestSpecificValues.Current_Mode.BibID, vid, UI_ApplicationCache_Gateway.Icon_List, RequestSpecificValues.Tracer); SobekCM_Item saveItem = itemAndError.Item1; // Clear some values for this item saveItem.VID = String.Empty; saveItem.Divisions.Clear(); saveItem.Behaviors.Serial_Info.Clear(); saveItem.Bib_Info.Series_Part_Info.Clear(); saveItem.Behaviors.Clear_Ticklers(); saveItem.Tracking.Internal_Comments = String.Empty; saveItem.Bib_Info.Location.PURL = String.Empty; saveItem.Behaviors.Main_Thumbnail = String.Empty; saveItem.METS_Header.Create_Date = DateTime.Now; saveItem.METS_Header.Modify_Date = saveItem.METS_Header.Create_Date; saveItem.METS_Header.Creator_Software = "SobekCM Web - Online add a volume (derived from VID " + vid + ")"; saveItem.METS_Header.Clear_Creator_Individual_Notes(); saveItem.METS_Header.Creator_Individual = RequestSpecificValues.Current_User.Full_Name; saveItem.Bib_Info.Location.Other_URL = String.Empty; saveItem.Bib_Info.Location.Other_URL_Display_Label = String.Empty; saveItem.Bib_Info.Location.Other_URL_Note = String.Empty; // Save the CompleteTemplate changes to this item completeTemplate.Save_To_Bib(saveItem, RequestSpecificValues.Current_User, 1); // Save this item and copy over complete_item_submission(saveItem, RequestSpecificValues.Tracer); // Clear the volume list CachedDataManager.Items.Remove_Items_In_Title(saveItem.BibID, RequestSpecificValues.Tracer); CachedDataManager.Items.Remove_Items_List(saveItem.BibID, RequestSpecificValues.Tracer); // Also clear the engine SobekEngineClient.Items.Clear_Item_Group_Cache(saveItem.BibID, RequestSpecificValues.Tracer); // Also clear any searches or browses ( in the future could refine this to only remove those // that are impacted by this save... but this is good enough for now ) CachedDataManager.Clear_Search_Results_Browses(); // Forward differently depending on request switch (hidden_request) { case "save_edit": RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Edit_Item_Metadata; RequestSpecificValues.Current_Mode.VID = saveItem.VID; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); 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": RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.File_Management; RequestSpecificValues.Current_Mode.VID = saveItem.VID; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); break; default: RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display; RequestSpecificValues.Current_Mode.VID = saveItem.VID; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); 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 WebContent_Usage_AdminViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <remarks> Postback from handling an edit or new aggregation is handled here in the constructor </remarks> public WebContent_Usage_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("WebContent_Usage_AdminViewer.Constructor", String.Empty); actionMessage = String.Empty; // Ensure the user is the system admin or portal admin if ((RequestSpecificValues.Current_User == null) || ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin))) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } //// If this is posted back, look for the reset //if (RequestSpecificValues.Current_Mode.isPostBack) //{ // string reset_value = HttpContext.Current.Request.Form[""]; // if ((!String.IsNullOrEmpty(reset_value)) && (reset_value == "reset")) // { // // Just ensure everything is emptied out // HttpContext.Current.Cache.Remove("GlobalPermissionsReport"); // HttpContext.Current.Cache.Remove("GlobalPermissionsUsersLinked"); // HttpContext.Current.Cache.Remove("GlobalPermissionsLinkedAggr"); // HttpContext.Current.Cache.Remove("GlobalPermissionsReportSubmit"); // } //} // Set filters initially to empty strings level1 = String.Empty; level2 = String.Empty; level3 = String.Empty; level4 = String.Empty; level5 = String.Empty; month1 = -1; year1 = -1; month2 = -1; year2 = -1; // Get any level filter information from the query string if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l1"])) { level1 = HttpContext.Current.Request.QueryString["l1"]; if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l2"])) { level2 = HttpContext.Current.Request.QueryString["l2"]; if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l3"])) { level3 = HttpContext.Current.Request.QueryString["l3"]; if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l4"])) { level4 = HttpContext.Current.Request.QueryString["l4"]; if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l5"])) { level5 = HttpContext.Current.Request.QueryString["l5"]; } } } } } // Get the year and month filters if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["d1"])) { string date1 = HttpContext.Current.Request.QueryString["d1"]; if (date1.Length == 6) { int year1possible; int month1possible; if ((Int32.TryParse(date1.Substring(0, 4), out year1possible)) && (Int32.TryParse(date1.Substring(4), out month1possible))) { year1 = year1possible; month1 = month1possible; } } } if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["d2"])) { string date2 = HttpContext.Current.Request.QueryString["d2"]; if (date2.Length == 6) { int year2possible; int month2possible; if ((Int32.TryParse(date2.Substring(0, 4), out year2possible)) && (Int32.TryParse(date2.Substring(4), out month2possible))) { year2 = year2possible; month2 = month2possible; } } } // If the end year is filled out, but not the month, set to the end of that year if ((year2 > 1900) && (month2 < 1) || (month2 > 12)) { month2 = (year2 == DateTime.Now.Year) ? DateTime.Now.Month : 12; } // If no final year/month, set it to now as well if (year2 < 1900) { year2 = UI_ApplicationCache_Gateway.Stats_Date_Range.Latest_Year; month2 = UI_ApplicationCache_Gateway.Stats_Date_Range.Latest_Month; } // If no initial year/month, use the first stats date if ((year1 < 1900) || (year1 < UI_ApplicationCache_Gateway.Stats_Date_Range.Earliest_Year)) { year1 = UI_ApplicationCache_Gateway.Stats_Date_Range.Earliest_Year; month1 = UI_ApplicationCache_Gateway.Stats_Date_Range.Earliest_Month; } if ((month1 < 1) || (month1 > 12)) { month1 = 1; if (year1 == UI_ApplicationCache_Gateway.Stats_Date_Range.Earliest_Year) { month1 = UI_ApplicationCache_Gateway.Stats_Date_Range.Earliest_Month; } } }
/// <summary> Constructor for a new instance of the Aliases_AdminViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <remarks> Postback from handling an edit or new item aggregation alias is handled here in the constructor </remarks> public Aliases_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("Aliases_AdminViewer.Constructor", String.Empty); // Set action message to nothing to start actionMessage = String.Empty; // If the RequestSpecificValues.Current_User cannot edit this, go back if ((RequestSpecificValues.Current_User == null) || ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin))) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // If this is a postback, handle any events first if (RequestSpecificValues.Current_Mode.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 ((RequestSpecificValues.Current_User.Is_System_Admin) && (save_value.Length > 1)) { save_value = save_value.Substring(1); RequestSpecificValues.Tracer.Add_Trace("Aliases_AdminViewer.Constructor", "Delete alias '" + save_value + "'"); if (SobekCM_Database.Delete_Aggregation_Alias(save_value, RequestSpecificValues.Tracer)) { if (UI_ApplicationCache_Gateway.Collection_Aliases.ContainsKey(save_value)) { UI_ApplicationCache_Gateway.Collection_Aliases.Remove(save_value); } actionMessage = "Deleted existing aggregation alias <i>" + save_value + "</i>"; } } } else { RequestSpecificValues.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 (UI_ApplicationCache_Gateway.Aggregations[new_code.ToUpper()] != null) { actionMessage = "Aggregation with this code already exists"; } else if (UI_ApplicationCache_Gateway.Settings.Static.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, RequestSpecificValues.Tracer)) { if (UI_ApplicationCache_Gateway.Collection_Aliases.ContainsKey(save_value)) { UI_ApplicationCache_Gateway.Collection_Aliases[save_value] = new_code; } else { UI_ApplicationCache_Gateway.Collection_Aliases.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, RequestSpecificValues.Tracer)) { if (UI_ApplicationCache_Gateway.Collection_Aliases.ContainsKey(save_value)) { UI_ApplicationCache_Gateway.Collection_Aliases[save_value] = edit_code; } else { UI_ApplicationCache_Gateway.Collection_Aliases.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 Default_Metadata_AdminViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <remarks> Postback from handling a new project is handled here in the constructor </remarks> public Default_Metadata_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("Default_Metadata_AdminViewer.Constructor", String.Empty); // Set action message and entered values to nothing to start actionMessage = String.Empty; entered_code = String.Empty; entered_base = String.Empty; entered_name = String.Empty; entered_desc = String.Empty; // If the RequestSpecificValues.Current_User cannot edit this, go back if ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin)) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // If this is a postback, handle any events first if (RequestSpecificValues.Current_Mode.isPostBack) { try { // Pull the standard values NameValueCollection form = HttpContext.Current.Request.Form; string save_value = form["admin_project_tosave"].ToUpper().Trim(); string delete_value = form["admin_project_delete"].ToUpper().Trim(); string code_value = form["admin_project_code"].ToUpper().Trim(); // Was this a delete request? if ((RequestSpecificValues.Current_User.Is_System_Admin) && (delete_value.Length > 0)) { RequestSpecificValues.Tracer.Add_Trace("Default_Metadata_AdminViewer.Constructor", "Delete default metadata '" + delete_value + "'"); // Try to delete in the database if (SobekCM_Database.Delete_Default_Metadata(delete_value, RequestSpecificValues.Tracer)) { // Set the message actionMessage = "Deleted default metadata '" + delete_value + "'"; // Look for the file to delete as well string pmets_file = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "projects\\" + delete_value + ".pmets"; if (File.Exists(pmets_file)) { try { File.Delete(pmets_file); } catch { actionMessage = "Deleted default metadata '" + delete_value + "' but failed to delete associated pmets file"; } } } else { actionMessage = "Error encountered deleting default metadata '" + delete_value + "' from the database"; } Engine_ApplicationCache_Gateway.RefreshCollectionAliases(); } else if (save_value.Length > 0) // Or.. was this a save request { RequestSpecificValues.Tracer.Add_Trace("Default_Metadata_AdminViewer.Constructor", "Save default metadata '" + save_value + "'"); // Was this to save a new project (from the main page) or rename an existing (from the popup form)? if (save_value == code_value) { entered_code = code_value; entered_base = form["admin_project_base"].ToUpper().Trim(); entered_name = form["admin_project_name"].Trim().Replace("\"", "'"); entered_desc = form["admin_project_desc"].Trim().Replace("\"", "'"); if (entered_name.Length == 0) { entered_name = entered_code; } if (entered_desc.Length == 0) { entered_desc = entered_name; } // Ensure the code is valid first bool result = entered_code.All(C => Char.IsLetterOrDigit(C) || C == '_'); if (!result) { actionMessage = "ERROR: Default metadata CODE must contain only letters and numbers"; entered_code = entered_code.Replace("\"", ""); } else if (entered_code.Length == 0) { actionMessage = "ERROR: Default metadata CODE is required"; } else if (entered_code.Length > 20) { actionMessage = "ERROR: Default metadata CODE cannot be more than twenty characters long"; entered_code = entered_code.Substring(0, 20); } else if (entered_name.Length > 50) { actionMessage = "ERROR: Default metadata NAME cannot be more than fifty characters long"; entered_name = entered_name.Substring(0, 50); } else { // Save this new interface if (SobekCM_Database.Save_Default_Metadata(entered_code.ToUpper(), entered_name, entered_desc, -1, RequestSpecificValues.Tracer)) { actionMessage = "Saved new default metadata <i>" + save_value + "</i>"; entered_code = String.Empty; entered_base = String.Empty; entered_name = String.Empty; entered_desc = String.Empty; } else { actionMessage = "Unable to save new default metadata <i>" + save_value + "</i>"; } Engine_ApplicationCache_Gateway.RefreshCollectionAliases(); // Try to creating the PMETS file if there was a base PMETS code provided try { if (entered_base.Length > 0) { string pmets_file = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "projects\\" + code_value + ".pmets"; string base_pmets_file = UI_ApplicationCache_Gateway.Settings.Servers.Base_MySobek_Directory + "projects\\" + entered_base + ".pmets"; if (File.Exists(base_pmets_file)) { File.Copy(base_pmets_file, pmets_file, true); } } } catch (Exception) { actionMessage = "Error copying new default metadata METS to the project folder"; } } } else { string edit_name = form["form_project_name"].Trim().Replace("\"", "'"); string edit_description = form["form_project_desc"].Trim().Replace("\"", "'"); // Save this existing interface if (SobekCM_Database.Save_Default_Metadata(save_value.ToUpper(), edit_name, edit_description, -1, RequestSpecificValues.Tracer)) { actionMessage = "Renamed existing default metadata <i>" + save_value + "</i>"; } else { actionMessage = "Unable to rename existing default metadata <i>" + save_value + "</i>"; } Engine_ApplicationCache_Gateway.RefreshCollectionAliases(); } } } catch (Exception) { actionMessage = "Unknown exception occurred while processing your request"; } } UI_ApplicationCache_Gateway.ResetDefaultMetadataTemplates(); }
/// <summary> Constructor for a new instance of the Aggregations_Mgmt_AdminViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> /// <remarks> Postback from handling an edit or new aggregation is handled here in the constructor </remarks> public Aggregations_Mgmt_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("Aggregations_Mgmt_AdminViewer.Constructor", String.Empty); // Set some defaults actionMessage = String.Empty; enteredCode = String.Empty; enteredParent = String.Empty; enteredType = String.Empty; enteredShortname = String.Empty; enteredName = String.Empty; enteredDescription = String.Empty; enteredThematicHeading = String.Empty; enteredIsActive = true; enteredIsHidden = false; addedNewCollection = false; // If the user cannot edit this, go back if ((RequestSpecificValues.Current_User == null) || ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin))) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // If this is a postback, handle any events first if (RequestSpecificValues.Current_Mode.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, RequestSpecificValues.Current_User.Is_System_Admin, RequestSpecificValues.Current_User.Full_Name, RequestSpecificValues.Tracer, out delete_error); if (errorCode <= 0) { string delete_folder = UI_ApplicationCache_Gateway.Settings.Servers.Base_Design_Location + "aggregations\\" + delete_aggregation_code; if (!SobekCM_File_Utilities.Delete_Folders_Recursively(delete_folder)) { actionMessage = "Deleted '" + delete_aggregation_code.ToUpper() + "' aggregation<br /><br />Unable to remove aggregation directory<br /><br />Some of the files may be in use"; } else { actionMessage = "Deleted '" + delete_aggregation_code.ToUpper() + "' aggregation"; } } else { actionMessage = delete_error; } CachedDataManager.Aggregations.Clear(); // Reload the list of all codes, to include this new one and the new hierarchy lock (UI_ApplicationCache_Gateway.Aggregations) { Engine_Database.Populate_Code_Manager(UI_ApplicationCache_Gateway.Aggregations, RequestSpecificValues.Tracer); } } // If there is a reset request here, purge the aggregation from the cache if (reset_aggregation_code.Length > 0) { CachedDataManager.Aggregations.Remove_Item_Aggregation(reset_aggregation_code, RequestSpecificValues.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) { addedNewCollection = true; // 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(); string new_thematic_heading = form["admin_aggr_heading"].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>(); if (String.IsNullOrEmpty(new_parent)) { 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 (UI_ApplicationCache_Gateway.Aggregations[new_aggregation_code.ToUpper()] != null) { errors.Add("New code must be unique... <i>" + new_aggregation_code + "</i> already exists"); } else if (UI_ApplicationCache_Gateway.Settings.Static.Reserved_Keywords.Contains(new_aggregation_code.ToLower())) { errors.Add("That code is a system-reserved keyword. Try a different code."); } else { bool alphaNumericTest = new_aggregation_code.All(C => Char.IsLetterOrDigit(C) || C == '_' || C == '-'); if (!alphaNumericTest) { errors.Add("New aggregation code must be only letters and numbers"); new_aggregation_code = new_aggregation_code.Replace("\"", ""); } } // 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; enteredThematicHeading = new_thematic_heading; } 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) string thematicHeading = null; if (form["admin_aggr_heading"] != null) { int thematicHeadingId = Convert.ToInt32(form["admin_aggr_heading"]); foreach (Thematic_Heading thisHeading in UI_ApplicationCache_Gateway.Thematic_Headings) { if (thisHeading.ID == thematicHeadingId) { thematicHeading = thisHeading.Text; break; } } } // Create the new aggregation argument object New_Aggregation_Arguments args = new New_Aggregation_Arguments { Active = is_active, Code = new_aggregation_code, Description = new_description, External_Link = enteredLink, Hidden = is_hidden, Name = new_name, ParentCode = new_parent, ShortName = new_shortname, Thematic_Heading = thematicHeading, Type = correct_type, User = RequestSpecificValues.Current_User.Full_Name }; // Try to add this aggregation RestResponseMessage msg = SobekEngineClient.Aggregations.Add_New_Aggregation(args); // We are going to save some of the values here anyway, to assist with bulk adds enteredIsActive = is_active; enteredIsHidden = is_hidden; enteredParent = new_parent; enteredType = new_type; enteredLink = new_link; enteredThematicHeading = new_thematic_heading; if (msg.ErrorTypeEnum == ErrorRestTypeEnum.Successful) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation; RequestSpecificValues.Current_Mode.Aggregation = new_aggregation_code; actionMessage = "New item aggregation (" + new_aggregation_code.ToUpper() + ") saved successfully.<br /><br /><a href=\"" + UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode, true) + "\" target=\"" + new_aggregation_code + "_AGGR\">Click here to view the new aggregation</a>"; RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Administrative; RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Aggregations_Mgmt; // Clear all aggregation information (and thematic heading info) from the cache as well CachedDataManager.Aggregations.Clear(); } else { actionMessage = msg.Message; enteredCode = new_aggregation_code; enteredShortname = new_shortname; enteredName = new_name; enteredDescription = new_description; } } } } } catch { actionMessage = "General error while reading postback information"; } } }
/// <summary> Constructor for a new instance of the Home_AdminViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> public Home_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("Home_AdminViewer.Constructor", String.Empty); if ((RequestSpecificValues.Current_User == null) || ((!RequestSpecificValues.Current_User.Is_Portal_Admin) && (!RequestSpecificValues.Current_User.Is_System_Admin))) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.My_Sobek; RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } menu_preference = "brief"; if (RequestSpecificValues.Current_User != null) { menu_preference = RequestSpecificValues.Current_User.Get_Setting("Home_AdminViewer:View Preference", "brief"); } // Was this a post-back, which would only be due to a preference change if (RequestSpecificValues.Current_Mode.isPostBack) { // Get the new preference string new_preference = HttpContext.Current.Request.Form["admin_menu_preference"]; if ((!String.IsNullOrEmpty(new_preference)) && (new_preference != menu_preference)) { // Save the new preference menu_preference = new_preference; if (RequestSpecificValues.Current_User != null) { RequestSpecificValues.Current_User.Add_Setting("Home_AdminViewer:View Preference", menu_preference); Engine_Database.Set_User_Setting(RequestSpecificValues.Current_User.UserID, "Home_AdminViewer:View Preference", menu_preference); } } } // Add all the known categories categories_dictionary["common"] = new List <string>(); categories_dictionary["appearance"] = new List <string>(); categories_dictionary["collections"] = new List <string>(); categories_dictionary["items"] = new List <string>(); categories_dictionary["settings"] = new List <string>(); categories_dictionary["permissions"] = new List <string>(); categories_dictionary["web"] = new List <string>(); // Build the icons lists // Add collection wizard RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Add_Collection_Wizard; string addColUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); string addColIcon = " <a href=\"" + addColUrl + "\" title=\"" + ADD_COLLECTION_WIZARD_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.Wizard_Img + "\" /><span class=\"sbkHav_ButtonText\">Add Collection<br />Wizard</span></div></a>"; icons["Add Collection Wizard"] = addColIcon; categories_dictionary["common"].Add(addColIcon); // Edit item current web skin RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Skins_Single; RequestSpecificValues.Current_Mode.My_Sobek_SubMode = RequestSpecificValues.Current_Mode.Skin; string editCurrSkinUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); RequestSpecificValues.Current_Mode.My_Sobek_SubMode = String.Empty; string editCurrSkinIcon = " <a href=\"" + editCurrSkinUrl + "\" title=\"" + EDIT_CURR_SKIN_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.Skins_Img + "\" /><span class=\"sbkHav_ButtonText\">Edit Current<br />Web Skin</span></div></a>"; icons["Edit Current Web Skin"] = editCurrSkinIcon; categories_dictionary["common"].Add(editCurrSkinIcon); string usersIcon = String.Empty; if ((RequestSpecificValues.Current_User != null) && (RequestSpecificValues.Current_User.Is_System_Admin)) { // Edit users and groups RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Users; string usersUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); usersIcon = " <a href=\"" + usersUrl + "\" title=\"" + USERS_AND_GROUPS_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.Users_Img + "\" /><span class=\"sbkHav_ButtonText\">Users and Groups</span></div></a>"; icons["Users and Groups"] = usersIcon; categories_dictionary["common"].Add(usersIcon); } // Edit item current web skin (REPEAT FROM COMMON TASKS CATEGORY) categories_dictionary["appearance"].Add(editCurrSkinIcon); // Edit URL Portals RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.URL_Portals; string urlPortalsUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); string urlPortalsIcon = " <a href=\"" + urlPortalsUrl + "\" title=\"" + URL_PORTALS_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.Portals_Img + "\" /><span class=\"sbkHav_ButtonText\">URL Portals</span></div></a>"; icons["URL Portals"] = urlPortalsIcon; categories_dictionary["appearance"].Add(urlPortalsIcon); // Edit web skins RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Skins_Mgmt; string skinsUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); string skinsIcon = " <a href=\"" + skinsUrl + "\" title=\"" + WEB_SKINS_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.Skins_Img + "\" /><span class=\"sbkHav_ButtonText\">Web Skins</span></div></a>"; icons["Web Skins"] = skinsIcon; categories_dictionary["appearance"].Add(skinsIcon); // Add collection wizard (REPEAT FROM COMMON TASKS CATEGORY) categories_dictionary["collections"].Add(addColIcon); // Edit aggregation aliases RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Aliases; string aliasesUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); string aliasesIcon = " <a href=\"" + aliasesUrl + "\" title=\"" + ALIASES_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.Aliases_Img + "\" /><span class=\"sbkHav_ButtonText\">Aggregation<br />Aliases</span></div></a>"; icons["Aggregation Aliases"] = aliasesIcon; categories_dictionary["collections"].Add(aliasesIcon); // Edit item aggregations RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Aggregations_Mgmt; string aggrMgmtUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); string aggrMgmtIcon = " <a href=\"" + aggrMgmtUrl + "\" title=\"" + AGGR_MGMT_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.Aggregations_Img + "\" /><span class=\"sbkHav_ButtonText\">Aggregation<br />Management</span></div></a>"; icons["Aggregation Management"] = aggrMgmtIcon; categories_dictionary["collections"].Add(aggrMgmtIcon); // Edit Thematic Headings RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Thematic_Headings; string thematicHeadingUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); string thematicHeadingIcon = " <a href=\"" + thematicHeadingUrl + "\" title=\"" + THEMATIC_HEADING_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.Thematic_Heading_Img + "\" /><span class=\"sbkHav_ButtonText\">Thematic Headings</span></div></a>"; icons["Thematic Headings"] = thematicHeadingIcon; categories_dictionary["collections"].Add(thematicHeadingIcon); // Edit Default_Metadata RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Default_Metadata; string defaultMetadataUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); string defaultMetadataIcon = " <a href=\"" + defaultMetadataUrl + "\" title=\"" + DEFAULT_METADATA_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.Pmets_Img + "\" /><span class=\"sbkHav_ButtonText\">Default Metadata</span></div></a>"; icons["Default Metadata"] = defaultMetadataIcon; categories_dictionary["items"].Add(defaultMetadataIcon); // Edit wordmarks RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Wordmarks; string wordmarksUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); string wordmarksIcon = " <a href=\"" + wordmarksUrl + "\" title=\"" + WORDMARKS_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.Wordmarks_Img + "\" /><span class=\"sbkHav_ButtonText\">Wordmarks / Icons</span></div></a>"; icons["Wordmarks"] = wordmarksIcon; categories_dictionary["items"].Add(wordmarksIcon); // View and set SobekCM Builder Status RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Builder_Status; string builderUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); string builderIcon = " <a href=\"" + builderUrl + "\" title=\"" + BUILDER_STATUS_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.Gears_Img + "\" /><span class=\"sbkHav_ButtonText\">Builder Status</span></div></a>"; icons["Builder Status"] = builderIcon; categories_dictionary["items"].Add(builderIcon); // Edit IP Restrictions RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.IP_Restrictions; string restrictionsUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); string restrictionsIcon = " <a href=\"" + restrictionsUrl + "\" title=\"" + RESTRICTIONS_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.Firewall_Img + "\" /><span class=\"sbkHav_ButtonText\">IP Restriction<br />Ranges</span></div></a>"; icons["IP Restriction Ranges"] = restrictionsIcon; categories_dictionary["settings"].Add(restrictionsIcon); // Edit Settings RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Settings; string settingsUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); string settingsIcon = " <a href=\"" + settingsUrl + "\" title=\"" + SETTINGS_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.Settings_Img + "\" /><span class=\"sbkHav_ButtonText\">System-Wide<br />Settings</span></div></a>"; icons["System-Wide Settings"] = settingsIcon; categories_dictionary["settings"].Add(settingsIcon); // Reset cache RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Reset; string resetUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); string resetIcon = " <a href=\"" + resetUrl + "\" title=\"" + RESET_CACHE_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.Refresh_Img + "\" /><span class=\"sbkHav_ButtonText\">Reset Cache</span></div></a>"; icons["Reset Cache"] = resetIcon; categories_dictionary["settings"].Add(resetIcon); // View permissions report RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.User_Permissions_Reports; string permissionsUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); string permissionsIcon = " <a href=\"" + permissionsUrl + "\" title=\"" + PERMISSIONS_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.User_Permission_Img + "\" /><span class=\"sbkHav_ButtonText\">User Permissions<br />Reports</span></div></a>"; icons["User Permissions Reports"] = permissionsIcon; categories_dictionary["permissions"].Add(permissionsIcon); // Web content pages management RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.WebContent_Mgmt; string webContentUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); string webContentIcon = " <a href=\"" + webContentUrl + "\" title=\"" + WEB_MGMT_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.WebContent_Img + "\" /><span class=\"sbkHav_ButtonText\">Manage Web<br />Content Pages</span></div></a>"; icons["Web Content Pages"] = webContentIcon; categories_dictionary["web"].Add(webContentIcon); // Web content pages history RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.WebContent_History; string webHistoryUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); string webHistoryIcon = " <a href=\"" + webHistoryUrl + "\" title=\"" + WEB_HISTORY_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.WebContent_History_Img + "\" /><span class=\"sbkHav_ButtonText\">Web Content<br />Recent Changes</span></div></a>"; icons["Web Content Recent Changes"] = webHistoryIcon; categories_dictionary["web"].Add(webHistoryIcon); // Web content pages usage statistics RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.WebContent_Usage; string webUsageUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); string webUsageIcon = " <a href=\"" + webUsageUrl + "\" title=\"" + WEB_USAGE_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.WebContent_Usage_Img + "\" /><span class=\"sbkHav_ButtonText\">Web Content<br />Usage Reports</span></div></a>"; icons["Web Content Usage Statistics"] = webUsageIcon; categories_dictionary["web"].Add(webUsageIcon); // Check to see if the TEI extension should be added here // Ensure the plug-in list exists and contains the TEI plug-in if ((UI_ApplicationCache_Gateway.Configuration.Extensions != null) && (UI_ApplicationCache_Gateway.Configuration.Extensions.Get_Extension("TEI") != null) && (UI_ApplicationCache_Gateway.Configuration.Extensions.Get_Extension("TEI").Enabled)) { categories_dictionary["extensions"] = new List <string>(); RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.TEI; string teiUrl = UrlWriterHelper.Redirect_URL(RequestSpecificValues.Current_Mode); string teiIcon = " <a href=\"" + teiUrl + "\" title=\"" + TEI_BRIEF + "\"><div class=\"sbkHav_ButtonDiv\"><img src=\"" + Static_Resources_Gateway.Settings_Img + "\" /><span class=\"sbkHav_ButtonText\">Manage TEI plug-in</span></div></a>"; icons["Manage TEI plug-in"] = teiIcon; categories_dictionary["extensions"].Add(teiIcon); } // Edit users (REPEAT FROM COMMON TASKS CATEGORY) if ((RequestSpecificValues.Current_User != null) && (RequestSpecificValues.Current_User.Is_System_Admin)) { // Edit users categories_dictionary["permissions"].Add(usersIcon); } RequestSpecificValues.Current_Mode.Admin_Type = Admin_Type_Enum.Home; }
/// <summary> Constructor for a new instance of the File_Management_MySobekViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> public File_Management_MySobekViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", String.Empty); // If no user then that is an error if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn)) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation; RequestSpecificValues.Current_Mode.Aggregation = String.Empty; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // Ensure BibID and VID provided RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "Validate provided bibid / vid"); if ((String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.BibID)) || (String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.VID))) { RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "BibID or VID was not provided!"); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error; RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : BibID/VID missing in item file upload request"; return; } RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "Try to pull this sobek complete item"); currentItem = SobekEngineClient.Items.Get_Sobek_Item(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Current_Mode.VID, RequestSpecificValues.Current_User.UserID, RequestSpecificValues.Tracer); if (currentItem == null) { RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "Unable to build complete item"); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error; RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : Unable to build complete item"; return; } digitalResourceDirectory = currentItem.Source_Directory; // If the user cannot edit this currentItem, go back if (!RequestSpecificValues.Current_User.Can_Edit_This_Item(currentItem.BibID, currentItem.Bib_Info.SobekCM_Type_String, currentItem.Bib_Info.Source.Code, currentItem.Bib_Info.HoldingCode, currentItem.Behaviors.Aggregation_Code_List)) { RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // If this is post-back, handle it if (RequestSpecificValues.Current_Mode.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_" + currentItem.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") { currentItem.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); } // Special code for PDF files and their derivatives if (filename.IndexOf(".pdf", StringComparison.OrdinalIgnoreCase) > 0) { // Delete the PDF text if (File.Exists(digitalResourceDirectory + "\\" + filename.ToLower().Replace(".pdf", "_pdf.txt"))) { File.Delete(digitalResourceDirectory + "\\" + filename.ToLower().Replace(".pdf", "_pdf.txt")); } // Delete the PDF thumbnail if (File.Exists(digitalResourceDirectory + "\\" + filename.ToLower().Replace(".pdf", "thm.jpg"))) { File.Delete(digitalResourceDirectory + "\\" + filename.ToLower().Replace(".pdf", "thm.jpg")); } } // Forward UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); 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 session state List <string> keys = HttpContext.Current.Session.Keys.Cast <string>().Where(ThisKey => ThisKey.IndexOf("file_" + currentItem.Web.ItemID + "_") == 0).ToList(); foreach (string thisKey in keys) { HttpContext.Current.Session.Remove(thisKey); } // Redirect to the currentItem RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); break; case 9: if (!complete_item_submission(currentItem, null)) { // Clear all the file keys in the session state List <string> keys2 = HttpContext.Current.Session.Keys.Cast <string>().Where(ThisKey => ThisKey.IndexOf("file_" + currentItem.Web.ItemID + "_") == 0).ToList(); foreach (string thisKey in keys2) { HttpContext.Current.Session.Remove(thisKey); } // Remoe from the caches (to replace the other) CachedDataManager.Items.Remove_Digital_Resource_Object(currentItem.BibID, currentItem.VID, RequestSpecificValues.Tracer); // Also clear the engine SobekEngineClient.Items.Clear_Item_Cache(currentItem.BibID, currentItem.VID, RequestSpecificValues.Tracer); // Redirect to the currentItem RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } break; } } } }
/// <summary> Constructor for a new instance of the Edit_Item_Permissions_MySobekViewer class </summary> /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param> public Edit_Item_Permissions_MySobekViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues) { // If no user then that is an error if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn)) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation; RequestSpecificValues.Current_Mode.Aggregation = String.Empty; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); return; } // Ensure BibID and VID provided RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "Validate provided bibid / vid"); if ((String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.BibID)) || (String.IsNullOrEmpty(RequestSpecificValues.Current_Mode.VID))) { RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "BibID or VID was not provided!"); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error; RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : BibID/VID missing in item file upload request"; return; } RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "Try to pull this sobek complete item"); currentItem = SobekEngineClient.Items.Get_Sobek_Item(RequestSpecificValues.Current_Mode.BibID, RequestSpecificValues.Current_Mode.VID, RequestSpecificValues.Current_User.UserID, RequestSpecificValues.Tracer); if (currentItem == null) { RequestSpecificValues.Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", "Unable to build complete item"); RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Error; RequestSpecificValues.Current_Mode.Error_Message = "Invalid Request : Unable to build complete item"; return; } bool userCanEditItem = RequestSpecificValues.Current_User.Can_Edit_This_Item(currentItem.BibID, currentItem.Bib_Info.SobekCM_Type_String, currentItem.Bib_Info.Source.Code, currentItem.Bib_Info.HoldingCode, currentItem.Behaviors.Aggregation_Code_List); if (!userCanEditItem) { RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } // Start by setting the values by the item (good the first time user comes here) ipRestrictionMask = currentItem.Behaviors.IP_Restriction_Membership; isDark = currentItem.Behaviors.Dark_Flag; restrictedSelected = (ipRestrictionMask > 0); // Is there already a RightsMD module in the item? // Ensure this metadata module extension exists RightsMD_Info rightsInfo = currentItem.Get_Metadata_Module(GlobalVar.PALMM_RIGHTSMD_METADATA_MODULE_KEY) as RightsMD_Info; if ((rightsInfo != null) && (rightsInfo.Has_Embargo_End)) { embargoDate = rightsInfo.Embargo_End; } // Is this a postback? if (RequestSpecificValues.Current_Mode.isPostBack) { // Get the restriction mask and isDark flag if (HttpContext.Current.Request.Form["restrictionMask"] != null) { ipRestrictionMask = short.Parse(HttpContext.Current.Request.Form["restrictionMask"]); isDark = bool.Parse(HttpContext.Current.Request.Form["isDark"]); } // Look for embargo date if (HttpContext.Current.Request.Form["embargoDateBox"] != null) { string embargoText = HttpContext.Current.Request.Form["embargoDateBox"]; DateTime embargoDateNew; if (DateTime.TryParse(embargoText, out embargoDateNew)) { embargoDate = embargoDateNew; } } // If this was restrcted, there will be some checkboxes to determine ip restriction mask short checked_mask = 0; // Determine the IP restriction mask foreach (IP_Restriction_Range thisRange in UI_ApplicationCache_Gateway.IP_Restrictions.IpRanges) { // Is this check box checked? if (HttpContext.Current.Request.Form["range" + thisRange.RangeID] != null) { checked_mask += ((short)Math.Pow(2, (thisRange.RangeID - 1))); } } // Handle any request from the internal header for the item if (HttpContext.Current.Request.Form["permissions_action"] != null) { // Pull the action value string action = HttpContext.Current.Request.Form["permissions_action"].Trim(); // Is this to change accessibility? if ((action == "public") || (action == "private") || (action == "restricted") || (action == "dark")) { switch (action) { case "public": ipRestrictionMask = 0; isDark = false; restrictedSelected = false; break; case "private": ipRestrictionMask = -1; isDark = false; restrictedSelected = false; break; case "restricted": ipRestrictionMask = short.Parse(HttpContext.Current.Request.Form["selectRestrictionMask"]); restrictedSelected = true; isDark = false; break; case "dark": isDark = true; restrictedSelected = false; break; } } } // Was the SAVE button pushed? if (HttpContext.Current.Request.Form["behaviors_request"] != null) { string behaviorRequest = HttpContext.Current.Request.Form["behaviors_request"]; if (behaviorRequest == "save") { currentItem.Behaviors.IP_Restriction_Membership = ipRestrictionMask; currentItem.Behaviors.Dark_Flag = isDark; if (checked_mask > 0) { ipRestrictionMask = checked_mask; } // Save this to the database if (SobekCM_Item_Database.Set_Item_Visibility(currentItem.Web.ItemID, ipRestrictionMask, isDark, embargoDate, RequestSpecificValues.Current_User.UserName)) { // Update the web.config Resource_Web_Config_Writer.Update_Web_Config(currentItem.Source_Directory, currentItem.Behaviors.Dark_Flag, ipRestrictionMask, currentItem.Behaviors.Main_Thumbnail); // Remove the cached item CachedDataManager.Items.Remove_Digital_Resource_Object(currentItem.BibID, currentItem.VID, RequestSpecificValues.Tracer); // Also clear the engine SobekEngineClient.Items.Clear_Item_Cache(currentItem.BibID, currentItem.VID, RequestSpecificValues.Tracer); // Also clear any searches or browses ( in the future could refine this to only remove those // that are impacted by this save... but this is good enough for now ) CachedDataManager.Clear_Search_Results_Browses(); } RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Item_Display; UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode); } } } }