/// <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 virtual 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);
        }
Exemplo n.º 2
0
        /// <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, SobekCM_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;
                Current_Mode.Redirect();
                return;
            }
            else
            {
                bool userCanEditItem = CurrentUser.Can_Edit_This_Item(CurrentItem);
                if (!userCanEditItem)
                {
                    Current_Mode.ViewerCode = String.Empty;
                    Current_Mode.Redirect();
                    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);
            }
        }
        public void Add_Main_Menu(TextWriter Output, string CurrentCode, bool ItemRestrictedFromUserByIP, bool ItemCheckedOutByOtherUser, BriefItemInfo CurrentItem, Navigation_Object CurrentMode, User_Object CurrentUser, bool Include_Links, Custom_Tracer Tracer)
        {
            // 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>");

            // 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, Include_Links);
            }

            // 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();
        }