public Can_Edit_This_Item ( string BibID, string ItemType, string SourceCode, string HoldingCode, ICollection |
||
BibID | string | BibID for the item |
ItemType | string | Type of the item |
SourceCode | string | Source code for the item |
HoldingCode | string | Holding code for the item |
Aggregations | ICollection |
List of all aggregations codes linked to the item |
Résultat | bool |
/// <summary> Constructor for a new instance of the ManageMenu_ItemViewer class </summary> /// <param name="Current_Object"> Digital resource to display </param> /// <param name="Current_User"> Current user for this session </param> /// <param name="Current_Mode"> Navigation object which encapsulates the user's current request </param> public ManageMenu_ItemViewer(SobekCM_Item Current_Object, User_Object Current_User, Navigation_Object Current_Mode) { // Save the current user and current mode information (this is usually populated AFTER the constructor completes, // but in this case (QC viewer) we need the information for early processing CurrentMode = Current_Mode; CurrentUser = Current_User; CurrentItem = Current_Object; // Determine if this user can edit this item if (CurrentUser == null) { Current_Mode.ViewerCode = String.Empty; UrlWriterHelper.Redirect(Current_Mode); return; } else { bool userCanEditItem = CurrentUser.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) { Current_Mode.ViewerCode = String.Empty; UrlWriterHelper.Redirect(Current_Mode); return; } } }
/// <summary> Constructor for a new instance of the Citation_MARC_ItemViewer class, used to display the /// descriptive citation in MARC21 format</summary> /// <param name="BriefItem"> Digital resource object </param> /// <param name="CurrentUser"> Current user, who may or may not be logged on </param> /// <param name="CurrentRequest"> Information about the current request </param> public Citation_MARC_ItemViewer(BriefItemInfo BriefItem, User_Object CurrentUser, Navigation_Object CurrentRequest) { // Save the arguments for use later this.BriefItem = BriefItem; this.CurrentUser = CurrentUser; this.CurrentRequest = CurrentRequest; // Set the behavior properties to the empy behaviors ( in the base class ) Behaviors = EmptyBehaviors; // Check to see if the user can edit this userCanEdit = false; if ( CurrentUser != null ) userCanEdit = CurrentUser.Can_Edit_This_Item(BriefItem.BibID, BriefItem.Type, BriefItem.Behaviors.Source_Institution_Aggregation, BriefItem.Behaviors.Holding_Location_Aggregation, BriefItem.Behaviors.Aggregation_Code_List); }
/// <summary> Flag indicates if the current user has access to this viewer for the item </summary> /// <param name="CurrentItem"> Digital resource to see if the current user has correct permissions to use this viewer </param> /// <param name="CurrentUser"> Current user, who may or may not be logged on </param> /// <param name="IpRestricted"> Flag indicates if this item is IP restricted AND if the current user is outside the ranges </param> /// <returns> TRUE if the user has access to use this viewer, otherwise FALSE </returns> public bool Has_Access(BriefItemInfo CurrentItem, User_Object CurrentUser, bool IpRestricted) { // If there is no user (or they aren't logged in) then obviously, they can't edit this if ((CurrentUser == null) || (!CurrentUser.LoggedOn)) { return false; } // If INTERNAL, user has access if ((CurrentUser.Is_Host_Admin) || (CurrentUser.Is_System_Admin) || (CurrentUser.Is_Portal_Admin) || (CurrentUser.Is_Internal_User)) return true; // See if this user can edit this item bool userCanEditItem = CurrentUser.Can_Edit_This_Item(CurrentItem.BibID, CurrentItem.Type, CurrentItem.Behaviors.Source_Institution_Aggregation, CurrentItem.Behaviors.Holding_Location_Aggregation, CurrentItem.Behaviors.Aggregation_Code_List); if (!userCanEditItem) { // Can't edit, so don't show and return FALSE return false; } // Apparently it can be shown return true; }
public void Add_Main_Menu(TextWriter Output, string CurrentCode, bool ItemRestrictedFromUserByIP, bool ItemCheckedOutByOtherUser, BriefItemInfo CurrentItem, Navigation_Object CurrentMode, User_Object CurrentUser, Custom_Tracer Tracer) { // Set some flags based on the resource type bool is_bib_level = (String.Compare(CurrentItem.Type, "BIB_LEVEL", StringComparison.OrdinalIgnoreCase) == 0); bool is_ead = (String.Compare(CurrentItem.Type, "EAD", StringComparison.OrdinalIgnoreCase) == 0); // Determine if this user can edit this item bool userCanEditItem = false; if (CurrentUser != null) { userCanEditItem = CurrentUser.Can_Edit_This_Item(CurrentItem.BibID, CurrentItem.Type, CurrentItem.Behaviors.Source_Institution_Aggregation, CurrentItem.Behaviors.Holding_Location_Aggregation, CurrentItem.Behaviors.Aggregation_Code_List); } // Can this user (if there is one) edit this item? bool canManage = (CurrentUser != null) && (CurrentUser.Can_Edit_This_Item(CurrentItem.BibID, CurrentItem.Type, CurrentItem.Behaviors.Source_Institution_Aggregation, CurrentItem.Behaviors.Holding_Location_Aggregation, CurrentItem.Behaviors.Aggregation_Code_List)); // Add the item views Output.WriteLine("<!-- Add the different view and social options -->"); Output.WriteLine("<nav class=\"sbkMenu_Bar\" id=\"sbkIsw_MenuBar\" role=\"navigation\" aria-label=\"Item menu\">"); Output.WriteLine("\t<h2 class=\"hidden-element\">Item menu</h2>"); // Check that this item is not checked out by another user bool itemCheckedOutByOtherUser = false; if (CurrentItem.Behaviors.Single_Use) { if (!Engine_ApplicationCache_Gateway.Checked_List.Check_Out(CurrentItem.Web.ItemID, HttpContext.Current.Request.UserHostAddress)) { itemCheckedOutByOtherUser = true; } } // Add the sharing buttons if this is not restricted by IP address or checked out if ((!ItemRestrictedFromUserByIP) && (!ItemCheckedOutByOtherUser) && (!CurrentMode.Is_Robot)) { string add_text = "Add"; string remove_text = "Remove"; string send_text = "Send"; string print_text = "Print"; if (canManage) { add_text = String.Empty; remove_text = String.Empty; send_text = String.Empty; print_text = String.Empty; } string logOnUrl = String.Empty; bool isLoggedOn = CurrentUser != null && CurrentUser.LoggedOn; if (!isLoggedOn) { string returnUrl = UrlWriterHelper.Redirect_URL(CurrentMode); CurrentMode.Mode = Display_Mode_Enum.My_Sobek; CurrentMode.My_Sobek_Type = My_Sobek_Type_Enum.Logon; CurrentMode.Return_URL = returnUrl; logOnUrl = UrlWriterHelper.Redirect_URL(CurrentMode); CurrentMode.Mode = Display_Mode_Enum.Item_Display; CurrentMode.Return_URL = String.Empty; } Output.WriteLine("\t<div id=\"menu-right-actions\">"); if (( CurrentItem.Web != null ) && ( CurrentItem.Web.ItemID > 0)) { string print_item_form_open_url = UI_ApplicationCache_Gateway.Settings.Servers.Engine_URL + "items/html/print/" + CurrentItem.BibID + "/" + CurrentItem.VID + "/" + CurrentMode.ViewerCode; Output.WriteLine("\t\t<span id=\"printbuttonitem\" class=\"action-sf-menu-item\" onclick=\"print_form_open('" + print_item_form_open_url + "');\"><img src=\"" + Static_Resources_Gateway.Printer_Png + "\" alt=\"\" style=\"vertical-align:middle\" /><span id=\"printbuttonspan\">" + print_text + "</span></span>"); } else { Output.WriteLine("\t\t<span id=\"printbuttonitem\" class=\"action-sf-menu-item\" onclick=\"window.print();return false;\"><img src=\"" + Static_Resources_Gateway.Printer_Png + "\" alt=\"\" style=\"vertical-align:middle\" /><span id=\"printbuttonspan\">" + print_text + "</span></span>"); } if (isLoggedOn) { string email_item_form_open_url = UI_ApplicationCache_Gateway.Settings.Servers.Engine_URL + "items/html/send/" + CurrentItem.BibID + "/" + CurrentItem.VID; Output.WriteLine("\t\t<span id=\"sendbuttonitem\" class=\"action-sf-menu-item\" onclick=\"email_form_open('" + email_item_form_open_url + "');\"><img src=\"" + Static_Resources_Gateway.Email_Png + "\" alt=\"\" style=\"vertical-align:middle\" /><span id=\"sendbuttonspan\">" + send_text + "</span></span>"); if ((CurrentItem.Web != null) && (CurrentItem.Web.ItemID > 0)) { if (CurrentUser.Is_In_Bookshelf(CurrentItem.BibID, CurrentItem.VID)) { Output.WriteLine("\t\t<span id=\"addbuttonitem\" class=\"action-sf-menu-item\" onclick=\"return remove_item_itemviewer();\"><img src=\"" + Static_Resources_Gateway.Minussign_Png + "\" alt=\"\" style=\"vertical-align:middle\" /><span id=\"addbuttonspan\">" + remove_text + "</span></span>"); } else { // Determine the URL string add_item_form_open_url = UI_ApplicationCache_Gateway.Settings.Servers.Engine_URL + "items/html/bookshelf/" + CurrentUser.UserID + "/" + CurrentItem.BibID + "/" + CurrentItem.VID; Output.WriteLine("\t\t<span id=\"addbuttonitem\" class=\"action-sf-menu-item\" onclick=\"add_item_form_open('" + add_item_form_open_url + "');return false;\"><img src=\"" + Static_Resources_Gateway.Plussign_Png + "\" alt=\"\" style=\"vertical-align:middle\" /><span id=\"addbuttonspan\">" + add_text + "</span></span>"); } } } else { Output.WriteLine("\t\t<span id=\"sendbuttonitem\" class=\"action-sf-menu-item\" onclick=\"window.location='" + logOnUrl + "';return false;\"><img src=\"" + Static_Resources_Gateway.Email_Png + "\" alt=\"\" style=\"vertical-align:middle\" /><span id=\"sendbuttonspan\">" + send_text + "</span></span>"); if ((CurrentItem.Web != null) && (CurrentItem.Web.ItemID > 0)) Output.WriteLine("\t\t<span id=\"addbuttonitem\" class=\"action-sf-menu-item\" onclick=\"window.location='" + logOnUrl + "';return false;\"><img src=\"" + Static_Resources_Gateway.Plussign_Png + "\" alt=\"\" style=\"vertical-align:middle\" /><span id=\"addbuttonspan\">" + add_text + "</span></span>"); } string share_item_form_open_url = UI_ApplicationCache_Gateway.Settings.Servers.Engine_URL + "items/html/share/" + CurrentItem.BibID + "/" + CurrentItem.VID; Output.WriteLine("\t\t<span id=\"sharebuttonitem\" class=\"action-sf-menu-item\" onclick=\"toggle_share_form('share_button', '" + share_item_form_open_url + "');\"><span id=\"sharebuttonspan\">Share</span></span>"); Output.WriteLine("\t</div>"); Output.WriteLine(); } Output.WriteLine("\t<ul class=\"sf-menu\" id=\"sbkIhs_Menu\">"); // Save the current view type ushort page = CurrentMode.Page.HasValue ? CurrentMode.Page.Value : (ushort)1; ushort subpage = CurrentMode.SubPage.HasValue ? CurrentMode.SubPage.Value : (ushort)1; string viewerCode = CurrentMode.ViewerCode; CurrentMode.SubPage = 0; // Add any PRE-MENU instance options string first_pre_menu_option = String.Empty; string second_pre_menu_option = String.Empty; string third_pre_menu_option = String.Empty; if (UI_ApplicationCache_Gateway.Settings.Contains_Additional_Setting("Item Viewer.Static First Menu Item")) first_pre_menu_option = UI_ApplicationCache_Gateway.Settings.Get_Additional_Setting("Item Viewer.Static First Menu Item"); if (UI_ApplicationCache_Gateway.Settings.Contains_Additional_Setting("Item Viewer.Static Second Menu Item")) second_pre_menu_option = UI_ApplicationCache_Gateway.Settings.Get_Additional_Setting("Item Viewer.Static Second Menu Item"); if (UI_ApplicationCache_Gateway.Settings.Contains_Additional_Setting("Item Viewer.Static Third Menu Item")) third_pre_menu_option = UI_ApplicationCache_Gateway.Settings.Get_Additional_Setting("Item Viewer.Static Third Menu Item"); if ((first_pre_menu_option.Length > 0) || (second_pre_menu_option.Length > 0) || (third_pre_menu_option.Length > 0)) { if (first_pre_menu_option.Length > 0) { string[] first_splitter = first_pre_menu_option.Replace("[", "").Replace("]", "").Split(";".ToCharArray()); if (first_splitter.Length > 0) { Output.WriteLine("\t\t<li><a href=\"" + first_splitter[1] + "\" title=\"" + HttpUtility.HtmlEncode(first_splitter[0]) + "\">" + HttpUtility.HtmlEncode(first_splitter[0]) + "</a></li>"); } } if (second_pre_menu_option.Length > 0) { string[] second_splitter = second_pre_menu_option.Replace("[", "").Replace("]", "").Split(";".ToCharArray()); if (second_splitter.Length > 0) { Output.WriteLine("\t\t<li><a href=\"" + second_splitter[1] + "\" title=\"" + HttpUtility.HtmlEncode(second_splitter[0]) + "\">" + HttpUtility.HtmlEncode(second_splitter[0]) + "</a></li>"); } } if (third_pre_menu_option.Length > 0) { string[] third_splitter = third_pre_menu_option.Replace("[", "").Replace("]", "").Split(";".ToCharArray()); if (third_splitter.Length > 0) { Output.WriteLine("\t\t<li><a href=\"" + third_splitter[1] + "\" title=\"" + HttpUtility.HtmlEncode(third_splitter[0]) + "\">" + HttpUtility.HtmlEncode(third_splitter[0]) + "</a></li>"); } } } // Add the item level viewers - collect the menu portions List<Item_MenuItem> menuItems = new List<Item_MenuItem>(); foreach (string viewType in CurrentItem.UI.Viewers_Menu_Order) { iItemViewerPrototyper prototyper = ItemViewer_Factory.Get_Viewer_By_ViewType(viewType); if (prototyper.Has_Access(CurrentItem, CurrentUser, ItemRestrictedFromUserByIP)) { prototyper.Add_Menu_items(CurrentItem, CurrentUser, CurrentMode, menuItems, ItemRestrictedFromUserByIP); } } // Now, get ready to start adding the menu items Dictionary<string, List<Item_MenuItem>> topMenuToChildren = new Dictionary<string, List<Item_MenuItem>>(StringComparer.OrdinalIgnoreCase); foreach (Item_MenuItem menuItem in menuItems) { if (topMenuToChildren.ContainsKey(menuItem.MenuStripText)) topMenuToChildren[menuItem.MenuStripText].Add(menuItem); else { topMenuToChildren[menuItem.MenuStripText] = new List<Item_MenuItem> {menuItem}; } } // Now, step through the menu items foreach (Item_MenuItem topMenuItem in menuItems) { HTML_Helper(Output, topMenuItem, CurrentMode, CurrentCode, topMenuToChildren ); } //// Add the item level views //foreach (BriefItem_BehaviorViewer thisView in CurrentItem.Behaviors.Viewers) //{ // if (((!itemRestrictedFromUserByIp) && (!CurrentItem.Behaviors.Dark_Flag)) || (thisView.View_Type == View_Enum.CITATION) || // (thisView.View_Type == View_Enum.ALL_VOLUMES) || // (thisView.View_Type == View_Enum.RELATED_IMAGES)) // { // // Special code for the CITATION view (TEMPORARY - v.3.2) // if (thisView.View_Type == View_Enum.CITATION) // { // if (CurrentMode.Is_Robot) // { // Output.Write("\t\t<li class=\"selected-sf-menu-item-link\"><a href=\"\">Description</a></li>"); // } // else // { // CurrentMode.ViewerCode = "citation"; // if (CurrentItem.Bib_Info.SobekCM_Type == TypeOfResource_SobekCM_Enum.EAD) // CurrentMode.ViewerCode = "description"; // if ((viewerCode == "citation") || (viewerCode == "marc") || (viewerCode == "metadata") || // (viewerCode == "usage") || (viewerCode == "description")) // { // Output.Write("\t\t<li class=\"selected-sf-menu-item-link\"><a href=\"" + UrlWriterHelper.Redirect_URL(CurrentMode) + "\">Description</a>"); // } // else // { // Output.Write("\t\t<li><a href=\"" + UrlWriterHelper.Redirect_URL(CurrentMode) + "\">Description</a>"); // } // Output.WriteLine("<ul>"); // if (CurrentItem.Bib_Info.SobekCM_Type == TypeOfResource_SobekCM_Enum.EAD) // Output.WriteLine("\t\t\t<li><a href=\"" + UrlWriterHelper.Redirect_URL(CurrentMode) + "\">Archival Description</a></li>"); // else // Output.WriteLine("\t\t\t<li><a href=\"" + UrlWriterHelper.Redirect_URL(CurrentMode) + "\">Standard View</a></li>"); // CurrentMode.ViewerCode = "marc"; // Output.WriteLine("\t\t\t<li><a href=\"" + UrlWriterHelper.Redirect_URL(CurrentMode) + "\">MARC View</a></li>"); // CurrentMode.ViewerCode = "metadata"; // Output.WriteLine("\t\t\t<li><a href=\"" + UrlWriterHelper.Redirect_URL(CurrentMode) + "\">Metadata</a></li>"); // CurrentMode.ViewerCode = "usage"; // Output.WriteLine("\t\t\t<li><a href=\"" + UrlWriterHelper.Redirect_URL(CurrentMode) + "\">Usage Statistics</a></li>"); // Output.WriteLine("\t\t</ul></li>"); // CurrentMode.ViewerCode = viewerCode; // } // } // else if (thisView.View_Type == View_Enum.ALL_VOLUMES) // { // string resource_type_upper = CurrentItem.Bib_Info.SobekCM_Type_String.ToUpper(); // string all_volumes = "All Volumes"; // if (resource_type_upper.IndexOf("NEWSPAPER") >= 0) // { // all_volumes = "All Issues"; // } // else if (resource_type_upper.IndexOf("MAP") >= 0) // { // all_volumes = "Related Maps"; // } // else if (resource_type_upper.IndexOf("AERIAL") >= 0) // { // all_volumes = "Related Flights"; // } // if (CurrentMode.Is_Robot) // { // Output.Write("\t\t<li><a href=\"" + UI_ApplicationCache_Gateway.Settings.Servers.Base_URL + "\\" + CurrentItem.BibID + "\">" + all_volumes + "</a></li>"); // } // else // { // CurrentMode.ViewerCode = "allvolumes"; // if ((viewerCode == "allvolumes") || (viewerCode == "allvolumes2") || // (viewerCode == "allvolumes3")) // { // Output.Write("\t\t<li class=\"selected-sf-menu-item-link\"><a href=\"" + UrlWriterHelper.Redirect_URL(CurrentMode) + "\">" + all_volumes + "</a>"); // } // else // { // Output.Write("\t\t<li><a href=\"" + UrlWriterHelper.Redirect_URL(CurrentMode) + "\">" + all_volumes + "</a>"); // } // Output.WriteLine("<ul>"); // CurrentMode.ViewerCode = "allvolumes"; // Output.WriteLine("\t\t\t<li><a href=\"" + UrlWriterHelper.Redirect_URL(CurrentMode) + "\">Tree View</a></li>"); // CurrentMode.ViewerCode = "allvolumes2"; // Output.WriteLine("\t\t\t<li><a href=\"" + UrlWriterHelper.Redirect_URL(CurrentMode) + "\">Thumbnails</a></li>"); // if ((CurrentUser != null) && (CurrentUser.LoggedOn) && (CurrentUser.Is_Internal_User)) // { // CurrentMode.ViewerCode = "allvolumes3"; // Output.WriteLine("\t\t\t<li><a href=\"" + UrlWriterHelper.Redirect_URL(CurrentMode) + "\">List View</a></li>"); // } // Output.WriteLine("\t\t</ul></li>"); // CurrentMode.ViewerCode = viewerCode; // } // } // else // { // List<string> item_nav_bar_link = Item_Nav_Bar_HTML_Factory.Get_Nav_Bar_HTML(thisView, CurrentItem.Bib_Info.SobekCM_Type_String, RequestSpecificValues.HTML_Skin.Base_Skin_Code, CurrentMode, -1, UI_ApplicationCache_Gateway.Translation, showZoomable, CurrentItem); // // Add each nav bar link // foreach (string this_link in item_nav_bar_link) // { // Output.WriteLine("\t\t" + this_link + ""); // } // } // } //} //// If this is citation or index mode, the number may be an invalid page sequence //if ((page <= 0) || // (CurrentMode.ViewerCode == View_Object.Viewer_Code_By_Type(View_Enum.RELATED_IMAGES)[0])) //{ // CurrentMode.Page = 1; //} //if ((CurrentItem.Web.Static_PageCount > 0) && (RequestSpecificValues.Current_Page == null)) //{ // RequestSpecificValues.Current_Page = CurrentItem.Web.Pages_By_Sequence[0]; //} //// Add each page display type //if ((RequestSpecificValues.Current_Page != null) && (!itemRestrictedFromUserByIp)) //{ // int page_seq = CurrentMode.Page.HasValue ? CurrentMode.Page.Value : 1; // string resourceType = CurrentItem.Bib_Info.SobekCM_Type_String.ToUpper(); // if (CurrentItem.Behaviors.Item_Level_Page_Views_Count > 0) // { // List<string> pageViewLinks = new List<string>(); // foreach (View_Object thisPageView in CurrentItem.Behaviors.Item_Level_Page_Views) // { // View_Enum thisViewType = thisPageView.View_Type; // foreach (SobekCM_File_Info thisFile in RequestSpecificValues.Current_Page.Files) // { // View_Object fileObject = thisFile.Get_Viewer(); // if ((fileObject != null) && (fileObject.View_Type == thisViewType)) // { // pageViewLinks.AddRange(Item_Nav_Bar_HTML_Factory.Get_Nav_Bar_HTML(thisFile.Get_Viewer(), resourceType, RequestSpecificValues.HTML_Skin.Base_Skin_Code, CurrentMode, page_seq, UI_ApplicationCache_Gateway.Translation, showZoomable, CurrentItem)); // } // } // } // if (CurrentItem.BibID == "UF00001672") // { // string filename = RequestSpecificValues.Current_Page.Files[0].File_Name_Sans_Extension + ".txt"; // SobekCM_File_Info newFile = new SobekCM_File_Info(filename); // pageViewLinks.AddRange(Item_Nav_Bar_HTML_Factory.Get_Nav_Bar_HTML(newFile.Get_Viewer(), resourceType, RequestSpecificValues.HTML_Skin.Base_Skin_Code, CurrentMode, page_seq, UI_ApplicationCache_Gateway.Translation, showZoomable, CurrentItem)); // } // // Only continue if there were views // if (pageViewLinks.Count > 0) // { // // Determine the name for this menu item // string menu_title = "Page Image"; // if (resourceType.IndexOf("MAP") >= 0) // { // menu_title = "Map Image"; // } // else if ((resourceType.IndexOf("AERIAL") >= 0) || (resourceType.IndexOf("PHOTOGRAPH") >= 0)) // { // menu_title = "Image"; // } // if ((CurrentItem.Images != null ) && ( CurrentItem.Images.Count > 1 )) // menu_title = menu_title + "s"; // // Get the link for the first page view // string link = pageViewLinks[0].Substring(pageViewLinks[0].IndexOf("href=\"") + 6); // link = link.Substring(0, link.IndexOf("\"")); // // Was this a match? // if ((CurrentMode.ViewerCode == page_seq + "t") || (CurrentMode.ViewerCode == page_seq + "x") || (CurrentMode.ViewerCode == page_seq + "j")) // { // Output.Write("\t\t<li class=\"selected-sf-menu-item-link\"><a href=\"" + link + "\">" + menu_title + "</a>"); // } // else // { // Output.Write("\t\t<li><a href=\"" + link + "\">" + menu_title + "</a>"); // } // Output.WriteLine("<ul>"); // foreach (string pageLink in pageViewLinks) // { // Output.WriteLine("\t\t\t<li>" + pageLink + "</li>"); // } // Output.WriteLine("\t\t</ul></li>"); // } // } //} //if (itemRestrictedFromUserByIp) //{ // List<string> restricted_nav_bar_link = Item_Nav_Bar_HTML_Factory.Get_Nav_Bar_HTML(new View_Object(View_Enum.RESTRICTED), CurrentItem.Bib_Info.SobekCM_Type_String.ToUpper(), RequestSpecificValues.HTML_Skin.Base_Skin_Code, CurrentMode, 0, UI_ApplicationCache_Gateway.Translation, showZoomable, CurrentItem); // Output.WriteLine("\t\t" + restricted_nav_bar_link[0] + ""); //} // Set current submode back CurrentMode.Page = page; CurrentMode.ViewerCode = viewerCode; CurrentMode.SubPage = subpage; Output.WriteLine("\t</ul>"); Output.WriteLine("</nav>"); Output.WriteLine(); Output.WriteLine("<!-- Initialize the main item menu -->"); Output.WriteLine("<script>"); Output.WriteLine("\tjQuery(document).ready(function () { jQuery('ul.sf-menu').superfish(); });"); Output.WriteLine("</script>"); Output.WriteLine(); }
/// <summary> Constructor for a new instance of the QC_ItemViewer class, used to perform quality control and /// create the structural metadata ( page names and divisions ) for an online digital resource </summary> /// <param name="BriefItem"> Digital resource object </param> /// <param name="CurrentUser"> Current user, who may or may not be logged on </param> /// <param name="CurrentRequest"> Information about the current request </param> /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param> public QC_ItemViewer(BriefItemInfo BriefItem, User_Object CurrentUser, Navigation_Object CurrentRequest, Custom_Tracer Tracer ) { // Save the arguments for use later this.BriefItem = BriefItem; this.CurrentUser = CurrentUser; this.CurrentRequest = CurrentRequest; // If there is no user, send to the login if (CurrentUser == null) { CurrentRequest.Mode = Display_Mode_Enum.My_Sobek; CurrentRequest.My_Sobek_Type = My_Sobek_Type_Enum.Logon; UrlWriterHelper.Redirect(CurrentRequest); return; } // If the user cannot edit this item, go back if (!CurrentUser.Can_Edit_This_Item(BriefItem.BibID, BriefItem.Type, BriefItem.Behaviors.Source_Institution_Aggregation, BriefItem.Behaviors.Holding_Location_Aggregation, BriefItem.Behaviors.Aggregation_Code_List)) { CurrentRequest.ViewerCode = String.Empty; UrlWriterHelper.Redirect(CurrentRequest); return; } //If there are no pages for this item, redirect to the image upload screen if ((BriefItem.Images == null ) || ( BriefItem.Images.Count == 0 )) { CurrentRequest.Mode = Display_Mode_Enum.My_Sobek; CurrentRequest.My_Sobek_Type = My_Sobek_Type_Enum.Page_Images_Management; UrlWriterHelper.Redirect(CurrentRequest); return; } // Get the links for the METS string greenstoneLocation = BriefItem.Web.Source_URL + "/"; complete_mets = greenstoneLocation + BriefItem.BibID + "_" + BriefItem.VID + ".mets.xml"; // MAKE THIS USE THE FILES.ASPX WEB PAGE if this is restricted (or dark) if ((BriefItem.Behaviors.Dark_Flag) || (BriefItem.Behaviors.IP_Restriction_Membership > 0)) { complete_mets = CurrentRequest.Base_URL + "files/" + BriefItem.BibID + "/" + BriefItem.VID + "/" + BriefItem.BibID + "_" + BriefItem.VID + ".mets.xml"; } // Get the special qc_item, which matches the passed in Current_Object, at least the first time. // If the QC work is already in process, we may find a temporary METS file to read. // Determine the in process directory for this userInProcessDirectory = UI_ApplicationCache_Gateway.Settings.Servers.In_Process_Submission_Location + "\\" + CurrentUser.UserName.Replace(".", "").Replace("@", "") + "\\qcwork\\" + BriefItem.BibID + "_" + BriefItem.VID; if (CurrentUser.ShibbID.Trim().Length > 0) userInProcessDirectory = UI_ApplicationCache_Gateway.Settings.Servers.In_Process_Submission_Location + "\\" + CurrentUser.ShibbID + "\\qcwork\\" + BriefItem.BibID + "_" + BriefItem.VID; // Make the folder for the user in process directory if (!Directory.Exists(userInProcessDirectory)) Directory.CreateDirectory(userInProcessDirectory); // Create the name for the tempoary METS file? metsInProcessFile = userInProcessDirectory + "\\" + BriefItem.BibID + "_" + BriefItem.VID + ".mets.xml"; // Is this work in the user's SESSION state? qc_item = HttpContext.Current.Session[BriefItem.BibID + "_" + BriefItem.VID + " QC Work"] as SobekCM_Item; if (qc_item == null) { //// Try to pull the full item //Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "Try to pull this sobek complete item"); //qc_item = SobekEngineClient.Items.Get_Sobek_Item(BriefItem.BibID, BriefItem.VID, CurrentUser.UserID, Tracer); //if (qc_item == null) //{ // Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "Unable to build complete item"); // CurrentRequest.Mode = Display_Mode_Enum.Error; // CurrentRequest.Error_Message = "Invalid Request : Unable to build complete item"; // return; //} ////Save to the User's session //HttpContext.Current.Session[BriefItem.BibID + "_" + BriefItem.VID + " QC Work"] = qc_item; // Is there a temporary METS for this item, which is not expired? if ((File.Exists(metsInProcessFile)) && (File.GetLastWriteTime(metsInProcessFile).Subtract(DateTime.Now).Hours < 8)) { // Read the temporary METS file, and use that to build the qc_item qc_item = SobekCM_Item_Factory.Get_Item(metsInProcessFile, BriefItem.BibID, BriefItem.VID, null, Tracer); qc_item.Source_Directory = SobekFileSystem.Resource_Network_Uri(BriefItem); } else { // Just read the normal otherwise ( if we had the ability to deep copy a SobekCM_Item, we could skip this ) qc_item = SobekCM_Item_Factory.Get_Item(BriefItem.BibID, BriefItem.VID, null, Tracer); } // Save to the session, so it is easily available for next time HttpContext.Current.Session[BriefItem.BibID + "_" + BriefItem.VID + " QC Work"] = qc_item; } // If no QC item, this is an error if (qc_item == null) { throw new ApplicationException("Unable to retrieve the item for Quality Control in QC_ItemViewer.Constructor"); } // perform pre-display work Perform_PreDisplay_Work(Tracer); // If there are NO pages, then send this to the upload if (qc_item.Divisions.Page_Count == 0) { CurrentRequest.Mode = Display_Mode_Enum.My_Sobek; CurrentRequest.My_Sobek_Type = My_Sobek_Type_Enum.Page_Images_Management; UrlWriterHelper.Redirect(CurrentRequest); return; } // Get the default QC profile qc_profile = UI_ApplicationCache_Gateway.Configuration.QualityControlTool.Get_Default_Profile(); // If this was a post-back keep the required height and width for the qc area allThumbnailsOuterDiv1Width = -1; allThumbnailsOuterDiv1Height = -1; string temp_width = HttpContext.Current.Request.Form["QC_window_width"] ?? String.Empty; string temp_height = HttpContext.Current.Request.Form["QC_window_height"] ?? String.Empty; if ((temp_width.Length > 0) && (temp_height.Length > 0)) { // Parse the values and save to the session if (Int32.TryParse(temp_width, out allThumbnailsOuterDiv1Width)) HttpContext.Current.Session["QC_AllThumbnailsWidth"] = allThumbnailsOuterDiv1Width; if (Int32.TryParse(temp_height, out allThumbnailsOuterDiv1Height)) HttpContext.Current.Session["QC_AllThumbnailsHeight"] = allThumbnailsOuterDiv1Height; } else { object session_width = HttpContext.Current.Session["QC_AllThumbnailsWidth"]; if (session_width != null) allThumbnailsOuterDiv1Width = (int)session_width; object session_height = HttpContext.Current.Session["QC_AllThumbnailsHeight"]; if (session_height != null) allThumbnailsOuterDiv1Height = (int)session_height; } // See if there were hidden requests hidden_request = HttpContext.Current.Request.Form["QC_behaviors_request"] ?? String.Empty; hidden_main_thumbnail = HttpContext.Current.Request.Form["Main_Thumbnail_File"] ?? String.Empty; hidden_move_relative_position = HttpContext.Current.Request.Form["QC_move_relative_position"] ?? String.Empty; hidden_move_destination_fileName = HttpContext.Current.Request.Form["QC_move_destination"] ?? String.Empty; autonumber_number_system = HttpContext.Current.Request.Form["Autonumber_number_system"] ?? String.Empty; string temp = HttpContext.Current.Request.Form["autonumber_mode_from_form"] ?? "0"; Int32.TryParse(temp, out autonumber_mode_from_form); autonumber_text_only = HttpContext.Current.Request.Form["Autonumber_text_without_number"] ?? String.Empty; autonumber_number_only = HttpContext.Current.Request.Form["Autonumber_number_only"] ?? String.Empty; autonumber_number_system = HttpContext.Current.Request.Form["Autonumber_number_system"] ?? String.Empty; hidden_autonumber_filename = HttpContext.Current.Request.Form["Autonumber_last_filename"] ?? String.Empty; temp = HttpContext.Current.Request.Form["QC_sortable_option"] ?? "-1"; // Check for sortable ( aka, Drag and drop pages ) setting - is it different than user's setting? if (Int32.TryParse(temp, out makeSortable) && (makeSortable > 0) && (makeSortable <= 3)) { if (makeSortable.ToString() != CurrentUser.Get_Setting("QC_ItemViewer:SortableMode", "NULL")) { CurrentUser.Add_Setting("QC_ItemViewer:SortableMode", makeSortable); SobekCM_Database.Set_User_Setting(CurrentUser.UserID, "QC_ItemViewer:SortableMode", makeSortable.ToString()); } } // Check for the autonumber option - is it different than user's setting? temp = HttpContext.Current.Request.Form["QC_autonumber_option"] ?? "-1"; if ((Int32.TryParse(temp, out autonumber_mode)) && (autonumber_mode >= 0) && (autonumber_mode <= 2)) { if (autonumber_mode.ToString() != CurrentUser.Get_Setting("QC_ItemViewer:AutonumberingMode", "NULL")) { CurrentUser.Add_Setting("QC_ItemViewer:AutonumberingMode", autonumber_mode); SobekCM_Database.Set_User_Setting(CurrentUser.UserID, "QC_ItemViewer:AutonumberingMode", autonumber_mode.ToString()); } } // Check for size of thumbnail specified from the URL - is it different than user's settings? if (CurrentRequest.Size_Of_Thumbnails > 0) { if (CurrentRequest.Size_Of_Thumbnails.ToString() != CurrentUser.Get_Setting("QC_ItemViewer:ThumbnailSize", "NULL")) { CurrentUser.Add_Setting("QC_ItemViewer:ThumbnailSize", CurrentRequest.Size_Of_Thumbnails); SobekCM_Database.Set_User_Setting(CurrentUser.UserID, "QC_ItemViewer:ThumbnailSize", CurrentRequest.Size_Of_Thumbnails.ToString()); } } //Get any notes/comments entered by the user notes = HttpContext.Current.Request.Form["txtComments"] ?? String.Empty; if (!(Int32.TryParse(HttpContext.Current.Request.Form["QC_Sortable"], out makeSortable))) makeSortable = 3; // If the hidden move relative position is BEFORE, it is before the very first page if (hidden_move_relative_position == "Before") hidden_move_destination_fileName = "[BEFORE FIRST]"; try { //Call the JavaScript autosave function based on the option selected bool autosaveCacheValue = true; bool autosaveCache = false; //Conversion result of autosaveCacheValue(conversion successful or not) saved in autosaveCache if (HttpContext.Current.Session["autosave_option"] != null) autosaveCache = bool.TryParse(HttpContext.Current.Session["autosave_option"].ToString(), out autosaveCacheValue); bool convert = bool.TryParse(HttpContext.Current.Request.Form["Autosave_Option"], out autosave_option); if (!convert && !autosaveCache) { autosave_option = true; } else if (!convert && autosaveCache) { autosave_option = autosaveCacheValue; } else { HttpContext.Current.Session["autosave_option"] = autosave_option; } } catch (Exception e) { throw new ApplicationException("Error retrieving auto save option. " + e.Message); } // Check for a previously set main thumbnail, or one from the requesting form if (!String.IsNullOrEmpty(hidden_main_thumbnail)) { HttpContext.Current.Session["main_thumbnail_" + qc_item.BibID + "_" + qc_item.VID] = hidden_main_thumbnail; } else if (HttpContext.Current.Session["main_thumbnail_" + qc_item.BibID + "_" + qc_item.VID] == null) { hidden_main_thumbnail = qc_item.Behaviors.Main_Thumbnail.Replace("thm.jpg", ""); HttpContext.Current.Session["main_thumbnail_" + qc_item.BibID + "_" + qc_item.VID] = hidden_main_thumbnail; } else { hidden_main_thumbnail = HttpContext.Current.Session["main_thumbnail_" + qc_item.BibID + "_" + qc_item.VID].ToString(); } //Get the list of associated errors for this item from the database int itemID = SobekCM_Item_Database.Get_ItemID(BriefItem.BibID, BriefItem.VID); Get_QC_Errors(itemID); // Perform any requested actions switch (hidden_request) { case "autosave": case "save": case "complete": //Save the current time HttpContext.Current.Session["QC_timeUpdated"] = DateTime.Now.ToString("hh:mm tt"); // Read the data from the http form, perform all requests, and // update the qc_item (also updates the session and temporary files) // Save this updated information in the temporary folder's METS file for reading later if necessary. if ((Save_From_Form_Request_To_Item(String.Empty, String.Empty)) && ((hidden_request == "save") || (hidden_request == "complete"))) { // If the user selected SAVE or COMPLETE, roll out the new version Move_Temp_Changes_To_Production(); // Redirect differently depending on SAVE or COMPLETE if (hidden_request == "save") { // Forward back to the QC form HttpContext.Current.Response.Redirect(HttpContext.Current.Request.RawUrl, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); CurrentRequest.Request_Completed = true; } else if (hidden_request == "complete") { // Forward to the item CurrentRequest.ViewerCode = String.Empty; UrlWriterHelper.Redirect(CurrentRequest); } } break; case "cancel": Cancel_Current_QC(); // Forward back to the default item view CurrentRequest.ViewerCode = String.Empty; UrlWriterHelper.Redirect(CurrentRequest); break; case "clear_pagination": ClearPagination(); HttpContext.Current.Response.Redirect(HttpContext.Current.Request.RawUrl, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); CurrentRequest.Request_Completed = true; break; case "clear_reorder": Clear_Pagination_And_Reorder_Pages(); HttpContext.Current.Response.Redirect(HttpContext.Current.Request.RawUrl, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); CurrentRequest.Request_Completed = true; break; case "save_error": string error_code = HttpContext.Current.Request.Form["QC_error_number"] ?? String.Empty; string affected_page_index = HttpContext.Current.Request.Form["QC_affected_file"] ?? String.Empty; SaveQcError(itemID, error_code, affected_page_index); break; case "delete_page": // Read the data from the http form, perform all requests, and // update the qc_item (also updates the session and temporary files) string filename_to_delete = HttpContext.Current.Request.Form["QC_affected_file"] ?? String.Empty; if (Save_From_Form_Request_To_Item(String.Empty, filename_to_delete)) { Delete_Resource_File(filename_to_delete); } // Since we deleted a page, we need to roll out our new version Move_Temp_Changes_To_Production(); HttpContext.Current.Response.Redirect(HttpContext.Current.Request.RawUrl, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); CurrentRequest.Request_Completed = true; break; case "delete_selected_pages": // Read the data from the http form, perform all requests, and // update the qc_item (also updates the session and temporary files) List<QC_Viewer_Page_Division_Info> selected_page_div_from_form; if (Save_From_Form_Request_To_Item(String.Empty, String.Empty, out selected_page_div_from_form)) { foreach (QC_Viewer_Page_Division_Info thisPage in selected_page_div_from_form) { if (( thisPage.METS_StructMap_Page_Node.Files != null ) && ( thisPage.METS_StructMap_Page_Node.Files.Count > 0 )) Delete_Resource_File(thisPage.METS_StructMap_Page_Node.Files[0].File_Name_Sans_Extension); } } // Since we deleted a page, we need to roll out our new version Move_Temp_Changes_To_Production(); HttpContext.Current.Response.Redirect(HttpContext.Current.Request.RawUrl, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); CurrentRequest.Request_Completed = true; break; case "move_selected_pages": // Read the data from the http form, perform all requests, and // update the qc_item (also updates the session and temporary files) Save_From_Form_Request_To_Item(hidden_move_destination_fileName, String.Empty); HttpContext.Current.Response.Redirect(HttpContext.Current.Request.RawUrl, false); HttpContext.Current.ApplicationInstance.CompleteRequest(); CurrentRequest.Request_Completed = true; break; } // Get the pages pre-order to be used everywhere else static_pages = qc_item.Divisions.Physical_Tree.Pages_PreOrder_With_Files; if (static_pages == null) static_pages = new List<abstract_TreeNode>(); }