コード例 #1
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;
                }
            }
        }
コード例 #2
0
        /// <summary> Constructor for a new instance of the Builder_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        public Builder_AdminViewer(User_Object User, SobekCM_Navigation_Object Current_Mode)
            : base(User)
        {
            currentMode = Current_Mode;

            // Ensure the user is the system admin
            if ((User == null) || ((!User.Is_System_Admin) && (!User.Is_Portal_Admin)))
            {
                Current_Mode.Mode          = Display_Mode_Enum.My_Sobek;
                Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                Current_Mode.Redirect();
                return;
            }

            // If this is a postback, handle any events first
            if ((Current_Mode.isPostBack) && (User.Is_System_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
                    SobekCM_Database.Set_Setting("Builder Operation Flag", save_value);
                    Current_Mode.Redirect();
                }
            }
        }
コード例 #3
0
        /// <summary> Constructor for a new instance of the Preferences_HtmlSubwriter class </summary>
        public Preferences_HtmlSubwriter(SobekCM_Navigation_Object Current_Mode)
        {
            currentMode = Current_Mode;

            // 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":
                    currentMode.Language = Web_Language_Enum.English;
                    break;

                case "fr":
                    currentMode.Language = Web_Language_Enum.French;
                    break;

                case "es":
                    currentMode.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;

                currentMode.Mode             = Display_Mode_Enum.Aggregation;
                currentMode.Aggregation_Type = Aggregation_Type_Enum.Home;
                currentMode.Redirect();
            }
        }
コード例 #4
0
        /// <summary> Constructor for a new instance of the Group_Add_Volume_MySobekViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="All_Items_Lookup"> Allows individual items to be retrieved by various methods as <see cref="Single_Item"/> objects.</param>
        /// <param name="Current_Item"> Individual digital resource to be edited by the user </param>
        /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param>
        /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param>
        /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param>
        /// <param name="Items_In_Title"> List of items within this title </param>
        /// <param name="Translator"> Language support object which handles simple translational duties </param>
        /// <param name="HTML_Skin_Collection"> HTML Web skin collection which controls the overall appearance of this digital library </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Group_Add_Volume_MySobekViewer(User_Object User,
                                              SobekCM_Navigation_Object Current_Mode,
                                              Item_Lookup_Object All_Items_Lookup,
                                              SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager,
                                              Dictionary <string, Wordmark_Icon> Icon_Table,
                                              SobekCM_Skin_Object HTML_Skin,
                                              SobekCM_Items_In_Title Items_In_Title,
                                              Language_Support_Info Translator,
                                              SobekCM_Skin_Collection HTML_Skin_Collection,
                                              Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", String.Empty);

            currentMode     = Current_Mode;
            item            = Current_Item;
            itemList        = All_Items_Lookup;
            codeManager     = Code_Manager;
            iconList        = Icon_Table;
            webSkin         = HTML_Skin;
            itemsInTitle    = Items_In_Title;
            base.Translator = Translator;
            skins           = HTML_Skin_Collection;

            // Set some defaults
            ipRestrict              = -1;
            title                   = String.Empty;
            date                    = String.Empty;
            level1                  = String.Empty;
            level2                  = String.Empty;
            level3                  = String.Empty;
            level1Order             = -1;
            level2Order             = -1;
            level3Order             = -1;
            hierarchyCopiedFromDate = false;
            message                 = String.Empty;
            trackingBox             = String.Empty;
            bornDigital             = false;
            materialRecdDate        = null;
            materialRecdNotes       = String.Empty;
            dispositionAdvice       = -1;
            dispositionAdviceNotes  = String.Empty;


            // If the user cannot edit this item, go back
            if (!user.Can_Edit_This_Item(item))
            {
                currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                currentMode.Redirect();
                return;
            }

            // Determine the default template code
            string template_code = "addvolume";

            if (!user.Include_Tracking_In_Standard_Forms)
            {
                template_code = "addvolume_notracking";
            }

            // Load this template
            template = Cached_Data_Manager.Retrieve_Template(template_code, Tracer);
            if (template != null)
            {
                Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Found template in cache");
            }
            else
            {
                Tracer.Add_Trace("Group_Add_Volume_MySobekViewer.Constructor", "Reading template file");

                // Read this template
                Template_XML_Reader reader = new Template_XML_Reader();
                template = new Template();
                reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\defaults\\" + template_code + ".xml", template, true);

                // Add the current codes to this template
                template.Add_Codes(Code_Manager);

                // Save this into the cache
                Cached_Data_Manager.Store_Template(template_code, template, Tracer);
            }

            // See if there was a hidden request
            string hidden_request = HttpContext.Current.Request.Form["action"] ?? String.Empty;

            // If this was a cancel request do that
            if (hidden_request == "cancel")
            {
                currentMode.Mode = Display_Mode_Enum.Item_Display;
                currentMode.Redirect();
            }
            else if (hidden_request.IndexOf("save") == 0)
            {
                // Get the VID that used as a source for this
                string vid = HttpContext.Current.Request.Form["base_volume"];

                if (string.IsNullOrEmpty(vid))
                {
                    message = "<span style=\"color: red\"><strong>No base volume selected!</strong></span>";
                }
                else
                {
                    try
                    {
                        // Get a new instance of this item
                        SobekCM_Item saveItem = SobekCM_Item_Factory.Get_Item(Current_Mode.BibID, vid, Icon_Table, null, Tracer);

                        // Clear some values for this item
                        saveItem.VID = String.Empty;
                        saveItem.Divisions.Clear();
                        saveItem.Behaviors.Serial_Info.Clear();
                        saveItem.Bib_Info.Series_Part_Info.Clear();
                        saveItem.Behaviors.Clear_Ticklers();
                        saveItem.Tracking.Internal_Comments   = String.Empty;
                        saveItem.Bib_Info.Location.PURL       = String.Empty;
                        saveItem.Behaviors.Main_Thumbnail     = String.Empty;
                        saveItem.METS_Header.Create_Date      = DateTime.Now;
                        saveItem.METS_Header.Modify_Date      = saveItem.METS_Header.Create_Date;
                        saveItem.METS_Header.Creator_Software = "SobekCM Web - Online add a volume (derived from VID " + vid + ")";
                        saveItem.METS_Header.Clear_Creator_Individual_Notes();
                        saveItem.METS_Header.Creator_Individual            = user.Full_Name;
                        saveItem.Bib_Info.Location.Other_URL               = String.Empty;
                        saveItem.Bib_Info.Location.Other_URL_Display_Label = String.Empty;
                        saveItem.Bib_Info.Location.Other_URL_Note          = String.Empty;

                        // Save the template changes to this item
                        template.Save_To_Bib(saveItem, user, 1);

                        // Save this item and copy over
                        complete_item_submission(saveItem, Tracer);

                        // Clear the volume list
                        Cached_Data_Manager.Remove_Items_In_Title(saveItem.BibID, Tracer);

                        // Forward differently depending on request
                        switch (hidden_request)
                        {
                        case "save_edit":
                            currentMode.Mode          = Display_Mode_Enum.My_Sobek;
                            currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Edit_Item_Metadata;
                            currentMode.VID           = saveItem.VID;
                            currentMode.Redirect();
                            break;

                        case "save_again":
                            // No redirect, but save values
                            date                   = saveItem.Bib_Info.Origin_Info.Date_Issued;
                            ipRestrict             = saveItem.Behaviors.IP_Restriction_Membership;
                            trackingBox            = saveItem.Tracking.Tracking_Box;
                            bornDigital            = saveItem.Tracking.Born_Digital;
                            dispositionAdvice      = saveItem.Tracking.Disposition_Advice;
                            dispositionAdviceNotes = saveItem.Tracking.Disposition_Advice_Notes;
                            materialRecdDate       = saveItem.Tracking.Material_Received_Date;
                            materialRecdNotes      = saveItem.Tracking.Material_Received_Notes;
                            if (!hierarchyCopiedFromDate)
                            {
                                if (saveItem.Behaviors.Serial_Info.Count > 0)
                                {
                                    level1      = saveItem.Behaviors.Serial_Info[0].Display;
                                    level1Order = saveItem.Behaviors.Serial_Info[0].Order;
                                }
                                if (saveItem.Behaviors.Serial_Info.Count > 1)
                                {
                                    level2      = saveItem.Behaviors.Serial_Info[1].Display;
                                    level2Order = saveItem.Behaviors.Serial_Info[1].Order;
                                }
                                if (saveItem.Behaviors.Serial_Info.Count > 2)
                                {
                                    level3      = saveItem.Behaviors.Serial_Info[2].Display;
                                    level3Order = saveItem.Behaviors.Serial_Info[2].Order;
                                }
                            }
                            message = message + "<span style=\"color: blue\"><strong>Saved new volume ( " + saveItem.BibID + " : " + saveItem.VID + ")</strong></span>";
                            break;

                        case "save_addfiles":
                            currentMode.Mode          = Display_Mode_Enum.My_Sobek;
                            currentMode.My_Sobek_Type = My_Sobek_Type_Enum.File_Management;
                            currentMode.VID           = saveItem.VID;
                            currentMode.Redirect();
                            break;

                        default:
                            currentMode.Mode = Display_Mode_Enum.Item_Display;
                            currentMode.VID  = saveItem.VID;
                            currentMode.Redirect();
                            break;
                        }
                    }
                    catch (Exception ee)
                    {
                        message = message + "<br /><span style=\"color: red\"><strong>EXCEPTION CAUGHT!<br /><br />" + ee.Message + "<br /><br />" + ee.StackTrace.Replace("\n", "<br />") + "</strong></span>";
                    }
                }
            }
        }
        /// <summary> Constructor for a new instance of the New_Group_And_Item_MySobekViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Current_Item"> Digital resource selected for file management </param>
        /// <param name="Item_List"> Allows individual items to be retrieved by various methods as <see cref="Single_Item"/> objects.</param>
        /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param>
        /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param>
        /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param>
        /// <param name="Translator"> Language support object which handles simple translational duties </param>
        /// <param name="HTML_Skin_Collection"> HTML Web skin collection which controls the overall appearance of this digital library </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public File_Management_MySobekViewer(User_Object User,
                                             SobekCM_Navigation_Object Current_Mode,
                                             SobekCM_Item Current_Item,
                                             Item_Lookup_Object Item_List,
                                             Aggregation_Code_Manager Code_Manager,
                                             Dictionary <string, Wordmark_Icon> Icon_Table,
                                             SobekCM_Skin_Object HTML_Skin,
                                             Language_Support_Info Translator,
                                             SobekCM_Skin_Collection HTML_Skin_Collection,
                                             Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("File_Management_MySobekViewer.Constructor", String.Empty);


            // Save the parameters
            codeManager              = Code_Manager;
            itemList                 = Item_List;
            iconList                 = Icon_Table;
            currentMode              = Current_Mode;
            webSkin                  = HTML_Skin;
            base.Translator          = Translator;
            item                     = Current_Item;
            digitalResourceDirectory = Current_Item.Source_Directory;
            skins                    = HTML_Skin_Collection;

            // If the user cannot edit this item, go back
            if (!user.Can_Edit_This_Item(item))
            {
                currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                currentMode.Redirect();
                return;
            }

            // If this is post-back, handle it
            if (currentMode.isPostBack)
            {
                string[] getKeys             = HttpContext.Current.Request.Form.AllKeys;
                string   file_name_from_keys = String.Empty;
                string   label_from_keys     = String.Empty;
                foreach (string thisKey in getKeys)
                {
                    if (thisKey.IndexOf("upload_file") == 0)
                    {
                        file_name_from_keys = HttpContext.Current.Request.Form[thisKey];
                    }
                    if (thisKey.IndexOf("upload_label") == 0)
                    {
                        label_from_keys = HttpContext.Current.Request.Form[thisKey];
                    }
                    if ((file_name_from_keys.Length > 0) && (label_from_keys.Length > 0))
                    {
                        HttpContext.Current.Session["file_" + item.Web.ItemID + "_" + file_name_from_keys.Trim()] = label_from_keys.Trim();
                        file_name_from_keys = String.Empty;
                        label_from_keys     = String.Empty;
                    }

                    if (thisKey == "url_input")
                    {
                        item.Bib_Info.Location.Other_URL = HttpContext.Current.Request.Form[thisKey];
                    }
                }

                string action = HttpContext.Current.Request.Form["action"];
                if (action == "delete")
                {
                    string filename = HttpContext.Current.Request.Form["phase"];
                    try
                    {
                        if (File.Exists(digitalResourceDirectory + "\\" + filename))
                        {
                            File.Delete(digitalResourceDirectory + "\\" + filename);
                        }

                        // Forward
                        currentMode.Redirect();
                        return;
                    }
                    catch
                    {
                        // Error was caught during attempted delete
                    }
                }

                if (action == "next_phase")
                {
                    int phase = Convert.ToInt32(HttpContext.Current.Request.Form["phase"]);
                    switch (phase)
                    {
                    case 2:
                        // Clear all the file keys in the session state
                        List <string> keys = HttpContext.Current.Session.Keys.Cast <string>().Where(ThisKey => ThisKey.IndexOf("file_" + item.Web.ItemID + "_") == 0).ToList();
                        foreach (string thisKey in keys)
                        {
                            HttpContext.Current.Session.Remove(thisKey);
                        }

                        // Redirect to the item
                        currentMode.Mode = Display_Mode_Enum.Item_Display;
                        currentMode.Redirect();
                        break;

                    case 9:
                        if (!complete_item_submission(item, null))
                        {
                            // Clear all the file keys in the session state
                            List <string> keys2 = HttpContext.Current.Session.Keys.Cast <string>().Where(ThisKey => ThisKey.IndexOf("file_" + item.Web.ItemID + "_") == 0).ToList();
                            foreach (string thisKey in keys2)
                            {
                                HttpContext.Current.Session.Remove(thisKey);
                            }

                            // Also clear the item from the cache
                            MemoryMgmt.Cached_Data_Manager.Remove_Digital_Resource_Object(item.BibID, item.VID, null);

                            // Redirect to the item
                            currentMode.Mode = Display_Mode_Enum.Item_Display;
                            currentMode.Redirect();
                        }
                        break;
                    }
                }
            }
        }
コード例 #6
0
        /// <summary> Constructor for a new instance of the Skins_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="CurrentMode"> Mode / navigation information for the current request</param>
        /// <param name="Web_Skin_Collection"> Contains the collection of all the default skins and the data to create any additional skins on request</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> Postback from handling an edit or new html skin is handled here in the constructor </remarks>
        public Skins_AdminViewer(User_Object User, SobekCM_Navigation_Object CurrentMode, SobekCM_Skin_Collection Web_Skin_Collection, Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Skins_AdminViewer.Constructor", String.Empty);

            // Save the mode and settings  here
            currentMode    = CurrentMode;
            skinCollection = Web_Skin_Collection;

            // Set action message to nothing to start
            actionMessage = String.Empty;

            // If the user cannot edit this, go back
            if ((!user.Is_System_Admin) && (!user.Is_Portal_Admin))
            {
                currentMode.Mode          = Display_Mode_Enum.My_Sobek;
                currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                currentMode.Redirect();
                return;
            }

            // If this is a postback, handle any events first
            if (currentMode.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)
                    {
                        Tracer.Add_Trace("Skins_AdminViewer.Constructor", "Reset html skin '" + reset_value + "'");

                        if (Web_Skin_Collection.Remove(reset_value))
                        {
                            actionMessage = "Removed skin <i>" + reset_value.ToUpper() + "</i> from the semi-permanent skin collection";
                        }
                        else
                        {
                            int values_cleared = Cached_Data_Manager.Remove_Skin(reset_value, 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 (user.Is_System_Admin)
                        {
                            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, Tracer))
                            {
                                // Set the deleted wordmark message
                                actionMessage = "Deleted web skin <i>" + delete_value + "</i>";

                                // Remove this web skin from the collection
                                SobekCM_Skin_Collection_Builder.Populate_Default_Skins(Web_Skin_Collection, Tracer);
                            }
                            else
                            {
                                // Report the error
                                if (SobekCM_Database.Last_Exception == null)
                                {
                                    actionMessage = "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)
                        {
                            Tracer.Add_Trace("Skins_AdminViewer.Constructor", "Save html skin '" + save_value + "'");

                            bool   override_banner  = false;
                            bool   override_header  = false;
                            bool   build_on_launch  = 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_header_override"];
                                if (temp_object != null)
                                {
                                    override_header = true;
                                }

                                temp_object = form["admin_interface_buildlaunch"];
                                if (temp_object != null)
                                {
                                    build_on_launch = 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;
                                }

                                // Save this new interface
                                if (SobekCM_Database.Save_Web_Skin(save_value, new_base_code, override_banner, override_header, new_banner_link, new_notes, build_on_launch, suppress_top_nav, Tracer))
                                {
                                    // Ensure a folder exists for this, otherwise create one
                                    try
                                    {
                                        string folder = SobekCM_Library_Settings.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   = currentMode.Skin;
                                                string current_web_folder = SobekCM_Library_Settings.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 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 = SobekCM_Library_Settings.Base_Design_Location + "skins/" + currentMode.Base_Skin;
                                                copy_entire_folder(base_skin_folder + "/buttons", folder + "/buttons");
                                                copy_entire_folder(base_skin_folder + "/tabs", folder + "/tabs");
                                                copy_entire_folder(base_skin_folder + "/zoom_controls", folder + "/zoom_controls");
                                            }
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        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 (skinCollection)
                                    {
                                        SobekCM_Skin_Collection_Builder.Populate_Default_Skins(skinCollection, 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(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value))
                                    {
                                        Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value);
                                    }
                                    if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\html"))
                                    {
                                        Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\html");
                                    }
                                    if (new_base_code.Length == 0)
                                    {
                                        if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\buttons"))
                                        {
                                            Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\buttons");
                                        }
                                        if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\tabs"))
                                        {
                                            Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\tabs");
                                        }
                                        if (!Directory.Exists(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\zoom_controls"))
                                        {
                                            Directory.CreateDirectory(SobekCM_Library_Settings.Base_Design_Location + "skins\\" + save_value + "\\zoom_controls");
                                        }
                                    }
                                }
                                catch (Exception)
                                {
                                    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_buildlaunch"];
                                if (temp_object != null)
                                {
                                    build_on_launch = 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, build_on_launch, suppress_top_nav, Tracer))
                                {
                                    lock (skinCollection)
                                    {
                                        SobekCM_Skin_Collection_Builder.Populate_Default_Skins(skinCollection, Tracer);
                                    }
                                    Cached_Data_Manager.Remove_Skin(save_value, 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.";
                }
            }
        }
コード例 #7
0
        /// <summary> Constructor for a new instance of the IP_Restrictions_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="CurrentMode"> Mode / navigation information for the current request</param>
        /// <param name="IP_Restrictions"> List of all IP restrictions ranges used in this digital library to restrict access to certain digital resources </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> Postback from handling an edit or new item aggregation alias is handled here in the constructor </remarks>
        public IP_Restrictions_AdminViewer(User_Object User, SobekCM_Navigation_Object CurrentMode, IP_Restriction_Ranges IP_Restrictions, Custom_Tracer Tracer) : base(User)
        {
            Tracer.Add_Trace("IP_Restrictions_AdminViewer.Constructor", String.Empty);

            ipRestrictionInfo = IP_Restrictions;
            currentMode       = CurrentMode;

            // Ensure the user is the system admin
            if ((User == null) || ((!User.Is_System_Admin) && (!User.Is_Portal_Admin)))
            {
                currentMode.Mode          = Display_Mode_Enum.My_Sobek;
                currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                currentMode.Redirect();
                return;
            }

            // Determine if there is an specific IP address range for editing
            index = -1;
            if (currentMode.My_Sobek_SubMode.Length > 0)
            {
                if (!Int32.TryParse(currentMode.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) && (index <= ipRestrictionInfo.Count))
            {
                thisRange = ipRestrictionInfo[index - 1];
                if (thisRange != null)
                {
                    details = SobekCM_Database.Get_IP_Restriction_Range_Details(thisRange.RangeID, Tracer);
                }
            }

            if ((currentMode.isPostBack) && (user.Is_System_Admin))
            {
                // Get a reference to this form
                NameValueCollection form = HttpContext.Current.Request.Form;

                string action = form["action"].Trim();

                if (action == "new")
                {
                    // Pull the main values
                    string title   = form["new_admin_title"].Trim();
                    string notes   = form["new_admin_notes"].Trim();
                    string message = form["new_admin_message"].Trim();

                    if ((title.Length == 0) || (message.Length == 0))
                    {
                        actionMessage = "Both title and message are required fields";
                    }
                    else
                    {
                        if (SobekCM_Database.Edit_IP_Range(-1, title, notes, message, Tracer))
                        {
                            actionMessage = "Saved new IP range '" + title + "'";
                        }
                        else
                        {
                            actionMessage = "Error saving new IP range '" + 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, 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, 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, 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, Tracer);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        actionMessage = "Error saving IP range";
                    }
                }


                // Repopulate the restriction table
                DataTable ipRestrictionTbl = SobekCM_Database.Get_IP_Restriction_Ranges(Tracer);
                if (ipRestrictionTbl != null)
                {
                    IP_Restrictions.Populate_IP_Ranges(ipRestrictionTbl);
                }

                // Forward back to the main form
                if (String.IsNullOrEmpty(actionMessage))
                {
                    currentMode.My_Sobek_SubMode = String.Empty;
                    currentMode.Redirect();
                }
            }
        }
        /// <summary> Constructor for a new instance of the Thematic_Headings_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request </param>
        /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param>
        /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> Postback from handling an edit or new thematic heading is handled here in the constructor </remarks>
        public Thematic_Headings_AdminViewer(User_Object User,
                                             SobekCM_Navigation_Object Current_Mode,
                                             List <Thematic_Heading> Thematic_Headings,
                                             Aggregation_Code_Manager Code_Manager,
                                             Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Thematic_Headings_AdminViewer.Constructor", String.Empty);

            // Get the current list of thematic headings
            thematicHeadings = Thematic_Headings;

            // Save the mode
            currentMode = Current_Mode;

            // Set action message to nothing to start
            actionMessage = String.Empty;

            // If the user cannot edit this, go back
            if ((!user.Is_System_Admin) && (!user.Is_Portal_Admin))
            {
                currentMode.Mode          = Display_Mode_Enum.My_Sobek;
                currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                currentMode.Redirect();
                return;
            }

            // Handle any post backs
            if (currentMode.isPostBack)
            {
                try
                {
                    // Pull the standard values from the form
                    NameValueCollection form = HttpContext.Current.Request.Form;
                    string save_value        = form["admin_heading_tosave"];
                    string action_value      = form["admin_heading_action"];

                    // Switch, depending on the request
                    if (action_value != null)
                    {
                        switch (action_value.Trim().ToLower())
                        {
                        case "edit":
                            string new_name = form["form_heading_name"];
                            if (new_name != null)
                            {
                                int id    = Convert.ToInt32(save_value);
                                int order = 1 + Thematic_Headings.TakeWhile(ThisHeading => ThisHeading.ThematicHeadingID != id).Count();
                                if (SobekCM_Database.Edit_Thematic_Heading(id, order, new_name, Tracer) < 1)
                                {
                                    actionMessage = "Unable to edit existing thematic heading";
                                }
                                else
                                {
                                    // For thread safety, lock the thematic headings list
                                    lock (Thematic_Headings)
                                    {
                                        // Repopulate the thematic headings list
                                        SobekCM_Database.Populate_Thematic_Headings(Thematic_Headings, Tracer);
                                    }

                                    actionMessage = "Thematic heading edits saved";
                                }
                            }
                            break;

                        case "delete":
                            int thematicDeleteId = Convert.ToInt32(save_value);
                            if (!SobekCM_Database.Delete_Thematic_Heading(thematicDeleteId, Tracer))
                            {
                                // Set action message
                                actionMessage = "Unable to delete existing thematic heading";
                            }
                            else
                            {
                                // For thread safety, lock the thematic headings list
                                lock (Thematic_Headings)
                                {
                                    // Remove this thematic heading from the list
                                    int i = 0;
                                    while (i < Thematic_Headings.Count)
                                    {
                                        if (Thematic_Headings[i].ThematicHeadingID == thematicDeleteId)
                                        {
                                            Thematic_Headings.RemoveAt(i);
                                        }
                                        else
                                        {
                                            i++;
                                        }
                                    }
                                }

                                // Set action message
                                actionMessage = "Thematic heading deleted";
                            }
                            break;


                        case "new":
                            int new_order = Thematic_Headings.Count + 1;
                            int newid     = SobekCM_Database.Edit_Thematic_Heading(-1, new_order, save_value, Tracer);
                            if (newid < 1)
                            {
                                actionMessage = "Unable to save new thematic heading";
                            }
                            else
                            {
                                // For thread safety, lock the thematic headings list
                                lock (Thematic_Headings)
                                {
                                    // Repopulate the thematic headings list
                                    SobekCM_Database.Populate_Thematic_Headings(Thematic_Headings, Tracer);
                                }

                                // Add this blank thematic heading to the code manager
                                Code_Manager.Add_Blank_Thematic_Heading(newid);

                                actionMessage = "New thematic heading saved";
                            }
                            break;

                        case "moveup":
                            string[] moveup_split = save_value.Split(",".ToCharArray());
                            int      moveup_id    = Convert.ToInt32(moveup_split[0]);
                            int      moveup_order = Convert.ToInt32(moveup_split[1]);
                            if (moveup_order > 1)
                            {
                                Thematic_Heading themeHeading = Thematic_Headings[moveup_order - 1];
                                if (themeHeading.ThematicHeadingID == moveup_id)
                                {
                                    // For thread safety, lock the thematic headings list
                                    lock (Thematic_Headings)
                                    {
                                        // Move this thematic heading up
                                        Thematic_Headings.Remove(themeHeading);
                                        Thematic_Headings.Insert(moveup_order - 2, themeHeading);
                                        int current_order = 1;
                                        foreach (Thematic_Heading thisTheme in Thematic_Headings)
                                        {
                                            SobekCM_Database.Edit_Thematic_Heading(thisTheme.ThematicHeadingID, current_order, thisTheme.ThemeName, Tracer);
                                            current_order++;
                                        }

                                        // Repopulate the thematic headings list
                                        SobekCM_Database.Populate_Thematic_Headings(Thematic_Headings, Tracer);
                                    }
                                }
                            }
                            break;

                        case "movedown":
                            string[] movedown_split = save_value.Split(",".ToCharArray());
                            int      movedown_id    = Convert.ToInt32(movedown_split[0]);
                            int      movedown_order = Convert.ToInt32(movedown_split[1]);
                            if (movedown_order < Thematic_Headings.Count)
                            {
                                Thematic_Heading themeHeading = Thematic_Headings[movedown_order - 1];
                                if (themeHeading.ThematicHeadingID == movedown_id)
                                {
                                    // For thread safety, lock the thematic headings list
                                    lock (Thematic_Headings)
                                    {
                                        // Move this thematic heading down
                                        Thematic_Headings.Remove(themeHeading);
                                        Thematic_Headings.Insert(movedown_order, themeHeading);
                                        int current_order = 1;
                                        foreach (Thematic_Heading thisTheme in Thematic_Headings)
                                        {
                                            SobekCM_Database.Edit_Thematic_Heading(thisTheme.ThematicHeadingID, current_order, thisTheme.ThemeName, Tracer);
                                            current_order++;
                                        }

                                        // Repopulate the thematic headings list
                                        SobekCM_Database.Populate_Thematic_Headings(Thematic_Headings, Tracer);
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
                catch (Exception)
                {
                    actionMessage = "Unknown error caught while handling your reqeust";
                }
            }
        }
        /// <summary> Constructor for a new instance of the Edit_Group_Behaviors_MySobekViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Current_Item"> Individual digital resource to be edited by the user </param>
        /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Edit_Group_Behaviors_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer) : base(User)
        {
            Tracer.Add_Trace("Edit_Group_Behaviors_MySobekViewer.Constructor", String.Empty);

            currentMode = Current_Mode;
            item        = Current_Item;


            // If the user cannot edit this item, go back
            if (!user.Can_Edit_This_Item(item))
            {
                currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                currentMode.Redirect();
                return;
            }

            const string TEMPLATE_CODE = "groupbehaviors";

            template = Cached_Data_Manager.Retrieve_Template(TEMPLATE_CODE, Tracer);
            if (template != null)
            {
                Tracer.Add_Trace("Edit_Group_Behaviors_MySobekViewer.Constructor", "Found template in cache");
            }
            else
            {
                Tracer.Add_Trace("Edit_Group_Behaviors_MySobekViewer.Constructor", "Reading template file");

                // Read this template
                Template_XML_Reader reader = new Template_XML_Reader();
                template = new Template();
                reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\defaults\\" + TEMPLATE_CODE + ".xml", template, true);

                // Add the current codes to this template
                template.Add_Codes(Code_Manager);

                // Save this into the cache
                Cached_Data_Manager.Store_Template(TEMPLATE_CODE, template, Tracer);
            }

            // See if there was a hidden request
            string hidden_request = HttpContext.Current.Request.Form["behaviors_request"] ?? String.Empty;

            // If this was a cancel request do that
            if (hidden_request == "cancel")
            {
                currentMode.Mode = Display_Mode_Enum.Item_Display;
                currentMode.Redirect();
            }
            else if (hidden_request == "save")
            {
                // Save these changes to bib
                template.Save_To_Bib(item, user, 1);

                // Save the group title
                SobekCM_Database.Update_Item_Group(item.BibID, item.Behaviors.GroupTitle, item.Bib_Info.SortSafeTitle(item.Behaviors.GroupTitle, true), String.Empty, item.Behaviors.Primary_Identifier.Type, item.Behaviors.Primary_Identifier.Identifier);

                // Save the interfaces to the group item as well
                SobekCM_Database.Save_Item_Group_Web_Skins(item.Web.GroupID, item);

                // Store on the caches (to replace the other)
                Cached_Data_Manager.Remove_Digital_Resource_Objects(item.BibID, Tracer);

                // Forward
                currentMode.Mode = Display_Mode_Enum.Item_Display;
                currentMode.Redirect();
            }
        }
コード例 #10
0
        /// <summary> Constructor for a new instance of the Mass_Update_Items_MySobekViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Current_Item"> Individual digital resource to be edited by the user </param>
        /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Mass_Update_Items_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer) : base(User)
        {
            Tracer.Add_Trace("Mass_Update_Items_MySobekViewer.Constructor", String.Empty);
            currentMode = Current_Mode;

            // Since this is a mass update, just create a new empty item with the GroupID included
            // from the provided item
            SobekCM_Item emptyItem = new SobekCM_Item {
                BibID = Current_Item.BibID
            };

            emptyItem.Web.GroupID          = Current_Item.Web.GroupID;
            emptyItem.Bib_Info.Source.Code = String.Empty;
            emptyItem.Behaviors.CheckOut_Required_Is_Null         = true;
            emptyItem.Behaviors.IP_Restriction_Membership_Is_Null = true;
            emptyItem.Behaviors.Dark_Flag_Is_Null = true;
            item = emptyItem;

            // If the user cannot edit this item, go back
            if (!user.Can_Edit_This_Item(Current_Item))
            {
                currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                currentMode.Redirect();
                return;
            }

            const string TEMPLATE_CODE = "massupdate";

            template = Cached_Data_Manager.Retrieve_Template(TEMPLATE_CODE, Tracer);
            if (template != null)
            {
                Tracer.Add_Trace("Mass_Update_Items_MySobekViewer.Constructor", "Found template in cache");
            }
            else
            {
                Tracer.Add_Trace("Mass_Update_Items_MySobekViewer.Constructor", "Reading template file");

                // Read this template
                Template_XML_Reader reader = new Template_XML_Reader();
                template = new Template();
                reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\defaults\\" + TEMPLATE_CODE + ".xml", template, true);

                // Add the current codes to this template
                template.Add_Codes(Code_Manager);

                // Save this into the cache
                Cached_Data_Manager.Store_Template(TEMPLATE_CODE, template, Tracer);
            }

            // See if there was a hidden request
            string hidden_request = HttpContext.Current.Request.Form["behaviors_request"] ?? String.Empty;

            // If this was a cancel request do that
            if (hidden_request == "cancel")
            {
                currentMode.Mode = Display_Mode_Enum.Item_Display;
                currentMode.Redirect();
            }
            else if (hidden_request == "save")
            {
                // Save these changes to bib
                template.Save_To_Bib(item, user, 1);

                // Save the behaviors
                SobekCM_Database.Save_Behaviors(item, false, true);

                // Store on the caches (to replace the other)
                Cached_Data_Manager.Remove_Digital_Resource_Objects(item.BibID, Tracer);

                // Forward
                currentMode.Mode = Display_Mode_Enum.Item_Display;
                currentMode.Redirect();
            }
        }
コード例 #11
0
        /// <summary> Constructor for a new instance of the Edit_Item_Metadata_MySobekViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="All_Items_Lookup"> Allows individual items to be retrieved by various methods as <see cref="Single_Item"/> objects.</param>
        /// <param name="Current_Item"> Individual digital resource to be edited by the user </param>
        /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param>
        /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param>
        /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param>
        /// <param name="HTML_Skin_Collection"> HTML Web skin collection which controls the overall appearance of this digital library </param>
        /// <param name="Translator"> Language support object which handles simple translational duties </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Edit_Item_Metadata_MySobekViewer(User_Object User,
                                                SobekCM_Navigation_Object Current_Mode,
                                                Item_Lookup_Object All_Items_Lookup,
                                                SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager,
                                                Dictionary <string, Wordmark_Icon> Icon_Table,
                                                SobekCM_Skin_Object HTML_Skin,
                                                Language_Support_Info Translator,
                                                SobekCM_Skin_Collection HTML_Skin_Collection,
                                                Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", String.Empty);

            currentMode     = Current_Mode;
            item            = Current_Item;
            itemList        = All_Items_Lookup;
            codeManager     = Code_Manager;
            iconList        = Icon_Table;
            webSkin         = HTML_Skin;
            popUpFormsHtml  = String.Empty;
            delayed_popup   = String.Empty;
            base.Translator = Translator;
            skins           = HTML_Skin_Collection;



            // If the user cannot edit this item, go back
            if (!user.Can_Edit_This_Item(item))
            {
                currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                HttpContext.Current.Response.Redirect(currentMode.Redirect_URL());
            }

            // Is this a project
            isProject = item.Bib_Info.SobekCM_Type == TypeOfResource_SobekCM_Enum.Project;

            string template_code = user.Edit_Template_Code;

            if ((isProject) || (item.Contains_Complex_Content) || (item.Using_Complex_Template))
            {
                template_code = user.Edit_Template_MARC_Code;
            }
            template = Cached_Data_Manager.Retrieve_Template(template_code, Tracer);
            if (template != null)
            {
                Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Found template in cache");
            }
            else
            {
                Tracer.Add_Trace("Edit_Item_Metadata_MySobekViewer.Constructor", "Reading template file");

                // Read this template
                Template_XML_Reader reader = new Template_XML_Reader();
                template = new Template();
                reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\edit\\" + template_code + ".xml", template, true);

                // Add the current codes to this template
                template.Add_Codes(Code_Manager);

                // Save this into the cache
                Cached_Data_Manager.Store_Template(template_code, template, Tracer);
            }

            // Get the current page number, or default to 1
            page = 1;
            if (currentMode.My_Sobek_SubMode.Length > 0)
            {
                if ((currentMode.My_Sobek_SubMode == "preview") || (currentMode.My_Sobek_SubMode == "marc") || (currentMode.My_Sobek_SubMode == "mets"))
                {
                    page = 0;
                }
                else
                {
                    page = 1;
                    bool isNumber = currentMode.My_Sobek_SubMode.All(Char.IsNumber);
                    if (isNumber)
                    {
                        if (isProject)
                        {
                            Double.TryParse(currentMode.My_Sobek_SubMode[0].ToString(), out page);
                        }
                        else
                        {
                            Double.TryParse(currentMode.My_Sobek_SubMode, out page);
                        }
                    }
                    else if (isProject)
                    {
                        if (Char.IsNumber(currentMode.My_Sobek_SubMode[0]))
                        {
                            Double.TryParse(currentMode.My_Sobek_SubMode[0].ToString(), out page);
                        }
                    }
                }
            }

            // Handle post backs
            if (Current_Mode.isPostBack)
            {
                // See if there was a hidden request
                string hidden_request = HttpContext.Current.Request.Form["new_element_requested"] ?? String.Empty;

                // If this was a cancel request do that
                if (hidden_request == "cancel")
                {
                    if (isProject)
                    {
                        Cached_Data_Manager.Remove_Project(user.UserID, item.BibID, null);

                        currentMode.Mode             = Display_Mode_Enum.Administrative;
                        currentMode.Admin_Type       = Admin_Type_Enum.Default_Metadata;
                        currentMode.My_Sobek_SubMode = String.Empty;
                        currentMode.Redirect();
                    }
                    else
                    {
                        Cached_Data_Manager.Remove_Digital_Resource_Object(user.UserID, item.BibID, item.VID, null);

                        currentMode.Mode = Display_Mode_Enum.Item_Display;
                        currentMode.Redirect();
                    }
                    return;
                }


                // Save these changes to bib
                template.Save_To_Bib(item, user, ((int)page));

                // See if the user asked for a new element of a complex form type
                delayed_popup = String.Empty;
                switch (hidden_request.Trim())
                {
                case "name":
                    delayed_popup = "name";
                    item.Bib_Info.Add_Named_Entity(String.Empty).Name_Type = Name_Info_Type_Enum.personal;
                    break;

                case "title":
                    delayed_popup = "title";
                    item.Bib_Info.Add_Other_Title(String.Empty, Title_Type_Enum.alternative);
                    break;

                case "subject":
                    delayed_popup = "subject";
                    item.Bib_Info.Add_Subject();
                    break;

                case "spatial":
                    delayed_popup = "spatial";
                    item.Bib_Info.Add_Hierarchical_Geographic_Subject();
                    break;

                case "relateditem":
                    delayed_popup = "relateditem";
                    item.Bib_Info.Add_Related_Item(new Related_Item_Info());
                    break;

                case "save":
                    Complete_Item_Save();
                    break;

                case "complicate":
                    item.Using_Complex_Template = true;
                    HttpContext.Current.Response.Redirect("?" + HttpContext.Current.Request.QueryString, false);
                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                    currentMode.Request_Completed = true;
                    return;

                case "simplify":
                    item.Using_Complex_Template = false;
                    HttpContext.Current.Response.Redirect("?" + HttpContext.Current.Request.QueryString, false);
                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                    currentMode.Request_Completed = true;
                    return;
                }

                // Was this for a new page?
                if (hidden_request.IndexOf("newpage") == 0)
                {
                    string page_requested = hidden_request.Replace("newpage", "");
                    if (page_requested != currentMode.My_Sobek_SubMode)
                    {
                        // forward to requested page
                        currentMode.My_Sobek_SubMode = page_requested;
                        if (currentMode.My_Sobek_SubMode == "0")
                        {
                            currentMode.My_Sobek_SubMode = "preview";
                        }
                        if (isProject)
                        {
                            currentMode.My_Sobek_SubMode = page_requested + item.BibID;
                        }

                        HttpContext.Current.Response.Redirect(currentMode.Redirect_URL() + "#template", false);
                        HttpContext.Current.ApplicationInstance.CompleteRequest();
                        currentMode.Request_Completed = true;
                    }
                }
            }
        }
        /// <summary> Constructor for a new instance of the Edit_Item_Behaviors_MySobekViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Current_Item"> Individual digital resource to be edited by the user </param>
        /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Edit_Item_Behaviors_MySobekViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, SobekCM_Item Current_Item, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer) : base(User)
        {
            Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", String.Empty);

            currentMode = Current_Mode;
            item        = Current_Item;

            // If the user cannot edit this item, go back
            if (!user.Can_Edit_This_Item(item))
            {
                currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                currentMode.Redirect();
                return;
            }

            const string TEMPLATE_CODE = "itembehaviors";

            template = Cached_Data_Manager.Retrieve_Template(TEMPLATE_CODE, Tracer);
            if (template != null)
            {
                Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "Found template in cache");
            }
            else
            {
                Tracer.Add_Trace("Edit_Item_Behaviors_MySobekViewer.Constructor", "Reading template file");

                // Read this template
                Template_XML_Reader reader = new Template_XML_Reader();
                template = new Template();
                reader.Read_XML(SobekCM_Library_Settings.Base_MySobek_Directory + "templates\\defaults\\" + TEMPLATE_CODE + ".xml", template, true);

                // Add the current codes to this template
                template.Add_Codes(Code_Manager);

                // Save this into the cache
                Cached_Data_Manager.Store_Template(TEMPLATE_CODE, template, Tracer);
            }

            // See if there was a hidden request
            string hidden_request = HttpContext.Current.Request.Form["behaviors_request"] ?? String.Empty;

            // If this was a cancel request do that
            if (hidden_request == "cancel")
            {
                currentMode.Mode = Display_Mode_Enum.Item_Display;
                currentMode.Redirect();
            }
            else if (hidden_request == "save")
            {
                // Changes to the tracking box require the metadata search citation be rebuilt for this item
                // so save the old tracking box information first
                string oldTrackingBox = item.Tracking.Tracking_Box;

                // Save these changes to bib
                template.Save_To_Bib(item, user, 1);

                // Save the behaviors
                SobekCM_Database.Save_Behaviors(item, item.Behaviors.Text_Searchable, false);

                // Save the serial hierarchy as well (sort of a behavior)
                SobekCM_Database.Save_Serial_Hierarchy_Information(item, item.Web.GroupID, item.Web.ItemID);

                // Did the tracking box change?
                if (item.Tracking.Tracking_Box != oldTrackingBox)
                {
                    SobekCM_Database.Create_Full_Citation_Value(item.Web.ItemID);
                }

                // Remoe from the caches (to replace the other)
                Cached_Data_Manager.Remove_Digital_Resource_Object(item.BibID, item.VID, Tracer);

                // Also remove the list of volumes, since this may have changed
                Cached_Data_Manager.Remove_Items_In_Title(item.BibID, Tracer);

                // Forward
                currentMode.Mode = Display_Mode_Enum.Item_Display;
                currentMode.Redirect();
            }
        }
コード例 #13
0
        /// <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="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Hierarchy_Object"> Current item aggregation object to display </param>
        public Contact_HtmlSubwriter(string Last_Mode, string UserHistoryRequestInfo, SobekCM_Navigation_Object Current_Mode, Item_Aggregation Hierarchy_Object)
        {
            // Save the parameters
            lastMode = Last_Mode;
            userHistoryRequestInfo   = UserHistoryRequestInfo;
            currentMode              = Current_Mode;
            this.Current_Aggregation = Hierarchy_Object;

            // 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")
            {
                string notes        = HttpContext.Current.Request.Form["notesTextBox"].Trim();
                string subject      = HttpContext.Current.Request.Form["subjectTextBox"].Trim();
                string message_from = SobekCM_Library_Settings.System_Email;
                string email        = HttpContext.Current.Request.Form["emailTextBox"].Trim();
                string name         = HttpContext.Current.Request.Form["nameTextBox"].Trim();

                if ((notes.Length > 0) || (subject.Length > 0))
                {
                    // Create the mail message
                    if (email.Length > 0)
                    {
                        message_from = email;
                    }

                    // Start the body
                    StringBuilder builder = new StringBuilder(1000);
                    builder.Append(notes + "\n\n\n\n");
                    builder.Append("The following information is collected to allow us better serve your needs.\n\n");
                    builder.Append("PERSONAL INFORMATION\n");
                    builder.Append("\tName:\t\t\t\t" + name + "\n");
                    builder.Append("\tEmail:\t\t\t" + email + "\n");
                    builder.Append(userHistoryRequestInfo);
                    string email_body = builder.ToString();

                    try
                    {
                        MailMessage myMail = new MailMessage(message_from, base.Current_Aggregation.Contact_Email.Replace(";", ","))
                        {
                            Subject = subject + "  [" + currentMode.SobekCM_Instance_Abbreviation + " Submission]",
                            Body    = email_body
                        };
                        // Mail this
                        SmtpClient client = new SmtpClient("smtp.ufl.edu");
                        client.Send(myMail);

                        // Log this
                        string sender = message_from;
                        if (name.Length > 0)
                        {
                            sender = name + " ( " + message_from + " )";
                        }
                        SobekCM_Database.Log_Sent_Email(sender, base.Current_Aggregation.Contact_Email.Replace(";", ","), subject + "  [" + currentMode.SobekCM_Instance_Abbreviation + " Submission]", email_body, false, true, -1);

                        // Send back to the home for this collection, sub, or group
                        Current_Mode.Mode = Display_Mode_Enum.Contact_Sent;
                        Current_Mode.Redirect();
                        return;
                    }
                    catch
                    {
                        bool email_error = SobekCM_Database.Send_Database_Email(base.Current_Aggregation.Contact_Email.Replace(";", ","), subject + "  [" + currentMode.SobekCM_Instance_Abbreviation + " Submission]", email_body, false, true, -1, -1);

                        // Send back to the home for this collection, sub, or group
                        if (email_error)
                        {
                            HttpContext.Current.Response.Redirect(SobekCM_Library_Settings.System_Error_URL, false);
                            HttpContext.Current.ApplicationInstance.CompleteRequest();
                            return;
                        }
                        else
                        {
                            // Send back to the home for this collection, sub, or group
                            Current_Mode.Mode = Display_Mode_Enum.Contact_Sent;
                            Current_Mode.Redirect();
                            return;
                        }
                    }
                }
            }
        }
コード例 #14
0
        /// <summary> Constructor for a new instance of the Portals_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="URL_Portals"> List of all web portals into this system </param>
        /// <param name="Web_Skin_Collection"> Contains the collection of all the default skins and the data to create any additional skins on request</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Portals_AdminViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Portal_List URL_Portals, SobekCM_Skin_Collection Web_Skin_Collection, Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Portals_AdminViewer.Constructor", String.Empty);

            portals        = URL_Portals;
            skinCollection = Web_Skin_Collection;

            // Save the mode
            currentMode = Current_Mode;

            // Set action message to nothing to start
            actionMessage = String.Empty;

            // If the user cannot edit this, go back
            if ((user == null) || ((!user.Is_System_Admin) && (!user.Is_Portal_Admin)))
            {
                Current_Mode.Mode          = Display_Mode_Enum.My_Sobek;
                Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                currentMode.Redirect();
                return;
            }

            // Handle any post backs
            if ((Current_Mode.isPostBack) && (user.Is_System_Admin))
            {
                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 = 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 = 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
                            {
                                // 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, 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), Tracer) ? "URL portal deleted" : "Error deleting the URL portal";
                            break;

                        case "new":
                            // Get the values from the form for this new portal
                            string new_name = form["admin_portal_name"];
                            string new_abbr = form["admin_portal_abbr"];
                            string new_skin = form["admin_portal_skin"];
                            string new_aggr = form["admin_portal_aggregation"];
                            string new_url  = form["admin_portal_url"];
                            string new_purl = form["admin_portal_purl"];

                            // Save this to the database
                            int new_id = SobekCM_Database.Edit_URL_Portal(-1, new_url, true, false, new_abbr, new_name, new_aggr, new_skin, new_purl, Tracer);
                            if (new_id > 0)
                            {
                                actionMessage = "Saved new URL portal '" + new_name + "'";
                            }
                            else
                            {
                                actionMessage = "Error saving URL portal.";
                            }
                            break;
                        }
                    }
                }
                catch (Exception)
                {
                    actionMessage = "Exception caught while handling request";
                }

                // Reload all the URL portals
                SobekCM_Database.Populate_URL_Portals(portals, Tracer);
            }
        }
コード例 #15
0
        /// <summary> Constructor for a new instance of the New_Group_And_Item_MySobekViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Current_Item"> Digital resource selected for file management </param>
        /// <param name="Item_List"> Allows individual items to be retrieved by various methods as <see cref="Single_Item"/> objects.</param>
        /// <param name="Code_Manager"> Code manager contains the list of all valid aggregation codes </param>
        /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param>
        /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param>
        /// <param name="Translator"> Language support object which handles simple translational duties </param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Page_Image_Upload_MySobekViewer(User_Object User,
                                               SobekCM_Navigation_Object Current_Mode,
                                               SobekCM_Item Current_Item,
                                               Item_Lookup_Object Item_List,
                                               Aggregation_Code_Manager Code_Manager,
                                               Dictionary <string, Wordmark_Icon> Icon_Table,
                                               SobekCM_Skin_Object HTML_Skin,
                                               Language_Support_Info Translator,
                                               Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Page_Image_Upload_MySobekViewer.Constructor", String.Empty);

            // Save the parameters
            codeManager           = Code_Manager;
            itemList              = Item_List;
            iconList              = Icon_Table;
            currentMode           = Current_Mode;
            webSkin               = HTML_Skin;
            this.validationErrors = validationErrors;
            base.Translator       = Translator;
            item = Current_Item;


            // If the user cannot edit this item, go back
            if (!user.Can_Edit_This_Item(item))
            {
                currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                currentMode.Redirect();
                return;
            }

            // Determine the in process directory for this
            digitalResourceDirectory = SobekCM_Library_Settings.In_Process_Submission_Location + "\\" + User.UserName.Replace(".", "").Replace("@", "") + "\\uploadimages\\" + Current_Item.METS_Header.ObjectID;
            if (User.ShibbID.Trim().Length > 0)
            {
                digitalResourceDirectory = SobekCM_Library_Settings.In_Process_Submission_Location + "\\" + User.ShibbID + "\\uploadimages\\" + Current_Item.METS_Header.ObjectID;
            }

            // Make the folder for the user in process directory
            if (!Directory.Exists(digitalResourceDirectory))
            {
                Directory.CreateDirectory(digitalResourceDirectory);
            }
            else
            {
                // Any post-processing to do?
                string[] files = Directory.GetFiles(digitalResourceDirectory);
                foreach (string thisFile in files)
                {
                    FileInfo thisFileInfo = new FileInfo(thisFile);
                    if ((thisFileInfo.Extension.ToUpper() == ".TIF") || (thisFileInfo.Extension.ToUpper() == ".TIFF"))
                    {
                        // Is there a JPEG and/or thumbnail?
                        string jpeg           = digitalResourceDirectory + "\\" + thisFileInfo.Name.Replace(thisFileInfo.Extension, "") + ".jpg";
                        string jpeg_thumbnail = digitalResourceDirectory + "\\" + thisFileInfo.Name.Replace(thisFileInfo.Extension, "") + "thm.jpg";

                        // Is one missing?
                        if ((!File.Exists(jpeg)) || (!File.Exists(jpeg_thumbnail)))
                        {
                            try
                            {
                                var tiffImg = System.Drawing.Image.FromFile(thisFile);
                                var mainImg = ScaleImage(tiffImg, SobekCM_Library_Settings.JPEG_Width, SobekCM_Library_Settings.JPEG_Height);
                                mainImg.Save(jpeg, ImageFormat.Jpeg);
                                var thumbnailImg = ScaleImage(tiffImg, 150, 400);
                                thumbnailImg.Save(jpeg_thumbnail, ImageFormat.Jpeg);
                            }
                            catch (Exception)
                            {
                                bool error = true;
                            }
                        }
                    }
                }
            }

            // If this is post-back, handle it
            if (currentMode.isPostBack)
            {
                string[] getKeys             = HttpContext.Current.Request.Form.AllKeys;
                string   file_name_from_keys = String.Empty;
                string   label_from_keys     = String.Empty;
                foreach (string thisKey in getKeys)
                {
                    if (thisKey.IndexOf("upload_file") == 0)
                    {
                        file_name_from_keys = HttpContext.Current.Request.Form[thisKey];
                    }
                    if (thisKey.IndexOf("upload_label") == 0)
                    {
                        label_from_keys = HttpContext.Current.Request.Form[thisKey];
                    }
                    if ((file_name_from_keys.Length > 0) && (label_from_keys.Length > 0))
                    {
                        HttpContext.Current.Session["file_" + item.Web.ItemID + "_" + file_name_from_keys.Trim()] = label_from_keys.Trim();
                        file_name_from_keys = String.Empty;
                        label_from_keys     = String.Empty;
                    }

                    if (thisKey == "url_input")
                    {
                        item.Bib_Info.Location.Other_URL = HttpContext.Current.Request.Form[thisKey];
                    }
                }

                string action = HttpContext.Current.Request.Form["action"];
                if (action == "delete")
                {
                    string filename = HttpContext.Current.Request.Form["phase"];
                    try
                    {
                        if (File.Exists(digitalResourceDirectory + "\\" + filename))
                        {
                            File.Delete(digitalResourceDirectory + "\\" + filename);
                        }

                        // Forward
                        currentMode.Redirect();
                        return;
                    }
                    catch
                    {
                        // Error was caught during attempted delete
                    }
                }

                if (action == "next_phase")
                {
                    int phase = Convert.ToInt32(HttpContext.Current.Request.Form["phase"]);
                    switch (phase)
                    {
                    case 2:
                        // Clear all the file keys in the temporary folder
                        string[] allFiles = Directory.GetFiles(digitalResourceDirectory);
                        foreach (string thisFile in allFiles)
                        {
                            try
                            {
                                File.Delete(thisFile);
                            }
                            catch
                            {
                                // Do nothing - not a fatal problem
                            }
                        }

                        try
                        {
                            Directory.Delete(digitalResourceDirectory);
                        }
                        catch
                        {
                            // Do nothing - not a fatal problem
                        }

                        // Redirect to the item
                        currentMode.Mode = Display_Mode_Enum.Item_Display;
                        currentMode.Redirect();
                        break;

                    case 9:
                        if (!complete_item_submission(item, null))
                        {
                            // Also clear the item from the cache
                            Cached_Data_Manager.Remove_Digital_Resource_Object(item.BibID, item.VID, null);

                            // Redirect to the item
                            currentMode.Mode       = Display_Mode_Enum.Item_Display;
                            currentMode.ViewerCode = "qc";
                            currentMode.Redirect();
                        }
                        break;
                    }
                }
            }
        }
コード例 #16
0
        /// <summary> Constructor for a new instance of the Preferences_MySobekViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="CurrentMode"> Mode / navigation information for the current request</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        public Preferences_MySobekViewer(User_Object User, SobekCM_Navigation_Object CurrentMode, Custom_Tracer Tracer) : base(User)
        {
            Tracer.Add_Trace("Preferences_MySobekViewer.Constructor", String.Empty);

            currentMode      = CurrentMode;
            validationErrors = new List <string>();

            // Set the text to use for each value (since we use if for the validation errors as well)
            mySobekText = "my" + currentMode.SobekCM_Instance_Abbreviation;

            // Get the labels to use, by language
            accountInfoLabel       = "Account Information";
            userNameLabel          = "UserName";
            personalInfoLabel      = "Personal Information";
            familyNamesLabel       = "Last/Family Name(s)";
            givenNamesLabel        = "First/Given Name(s)";
            nicknameLabel          = "Nickname";
            emailLabel             = "Email";
            emailStatsLabel        = "Send me monthly usage statistics for my items";
            affilitionInfoLabel    = "Current Affiliation Information";
            organizationLabel      = "Organization/University";
            collegeLabel           = "College";
            departmentLabel        = "Department";
            unitLabel              = "Unit";
            selfSubmittalPrefLabel = "Self-Submittal Preferences";
            sendEmailLabel         = "Send me an email when I submit new items";
            templateLabel          = "Template";
            projectLabel           = "Default Metadata";
            defaultRightsLabel     = "Default Rights";
            rightsExplanationLabel = "(These are the default rights you give for sharing, repurposing, or remixing your item to other users. You can set this with each new item you submit, but this will be the default that appears.)";
            rightsInstructionLabel = "You may also select a <a title=\"Explanation of different creative commons licenses.\" href=\"http://creativecommons.org/about/licenses/\">Creative Commons License</a> option below.";
            otherPreferencesLabel  = "Other Preferences";
            languageLabel          = "Language";
            passwordLabel          = "Password";
            confirmPasswordLabel   = "Confirm Password";
            col1Width              = "15px";
            col2Width              = "100px";
            col3Width              = "605px";

            if (currentMode.Language == Web_Language_Enum.French)
            {
                accountInfoLabel       = "Informations sur le Compte";
                userNameLabel          = "Nom du Compte";
                personalInfoLabel      = "Des Renseignements Personnels";
                familyNamesLabel       = "Nom de Famille";
                givenNamesLabel        = "Prénoms";
                nicknameLabel          = "Pseudo";
                emailLabel             = "Email";
                affilitionInfoLabel    = "Information Affiliation Actuel";
                organizationLabel      = "Organisation / Université";
                collegeLabel           = "Collège";
                departmentLabel        = "Département";
                unitLabel              = "Unité";
                selfSubmittalPrefLabel = "Préférences Auto-Soumission";
                sendEmailLabel         = "Envoyez-moi un email lorsque je présente les nouveaux éléments";
                templateLabel          = "Modèle";
                projectLabel           = "Métadonnées par Défaut";
                defaultRightsLabel     = "Droits par Défaut";
                rightsExplanationLabel = "(Ce sont les droits par défaut que vous donnez de partager, d'adapter, ou remixer votre article à d'autres utilisateurs. Vous pouvez fixer cette valeur à chaque nouvel élément que vous soumettez, mais ce sera la valeur par défaut qui s'affiche.)";
                rightsInstructionLabel = "Vous pouvez également sélectionner une option <a title=\"Explication des différentes licences Creative Commons.\" href=\"http://creativecommons.org/about/licenses/\">Creative Commons License</a> ci-dessous.";
                otherPreferencesLabel  = "Autres Préférences";
                languageLabel          = "Langue";
                passwordLabel          = "Mot de Passe";
                confirmPasswordLabel   = "Confirmer Mot de Passe";
                col1Width              = "10px";
                col2Width              = "220px";
                col3Width              = "490px";
            }

            if (currentMode.Language == Web_Language_Enum.Spanish)
            {
                accountInfoLabel       = "Información de la Cuenta";
                userNameLabel          = "Nombre de la Cuenta";
                personalInfoLabel      = "Información Personal";
                familyNamesLabel       = "Familia Nombre";
                givenNamesLabel        = "Nombre de Pila";
                nicknameLabel          = "Nickname";
                emailLabel             = "Correo Electrónico";
                affilitionInfoLabel    = "Información de la Afiliación Actual";
                organizationLabel      = "Organización/Universidad";
                collegeLabel           = "Colegio";
                departmentLabel        = "Departamento";
                unitLabel              = "Unidad";
                selfSubmittalPrefLabel = "Preferencias de Presentación Auto-";
                sendEmailLabel         = "Enviadme un correo electrónico cuando se presento nuevos temas";
                templateLabel          = "Plantilla";
                projectLabel           = "Metadatos Predeterminado";
                defaultRightsLabel     = "Derechos por Defecto";
                rightsExplanationLabel = "(Estos son los derechos por defecto le dan para compartir, reutilización, o remezclando el tema a otros usuarios. Puede establecer esto con cada artículo nuevo que presentar, pero esto será el valor por defecto que aparece.)";
                rightsInstructionLabel = "También puede seleccionar una opción de  <a title=\"Explicación de las diferentes licencias Creative Commons\" href=\"http://creativecommons.org/about/licenses/\">Creative Commons License</a> a continuación.";
                otherPreferencesLabel  = "Otras preferencias";
                languageLabel          = "Idioma";
                passwordLabel          = "Contraseña";
                confirmPasswordLabel   = "Confirmar Contraseña";
                col1Width              = "10px";
                col2Width              = "220px";
                col3Width              = "490px";
            }

            // Is this for registration
            registration = (HttpContext.Current.Session["user"] == null);
            if (registration)
            {
                user = new User_Object();
            }


            // Set some default first
            send_usages_emails = true;
            family_name        = String.Empty;
            given_name         = String.Empty;
            nickname           = String.Empty;
            email          = String.Empty;
            organization   = String.Empty;
            college        = String.Empty;
            department     = String.Empty;
            unit           = String.Empty;
            template       = String.Empty;
            project        = String.Empty;
            username       = String.Empty;
            password       = String.Empty;
            password2      = String.Empty;
            ufid           = String.Empty;
            language       = String.Empty;
            default_rights = String.Empty;

            // Handle post back
            if (currentMode.isPostBack)
            {
                // Loop through and get the dataa
                string[] getKeys = HttpContext.Current.Request.Form.AllKeys;
                foreach (string thisKey in getKeys)
                {
                    switch (thisKey)
                    {
                    case "prefUserName":
                        username = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "password_enter":
                        password = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "password_confirm":
                        password2 = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefUfid":
                        ufid = HttpContext.Current.Request.Form[thisKey].Trim().Replace("-", "");
                        break;

                    case "prefFamilyName":
                        family_name = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefGivenName":
                        given_name = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefNickName":
                        nickname = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefEmail":
                        email = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefOrganization":
                        organization = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefCollege":
                        college = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefDepartment":
                        department = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefUnit":
                        unit = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefLanguage":
                        string language_temp = HttpContext.Current.Request.Form[thisKey];
                        if (language_temp == "es")
                        {
                            language = "Español";
                        }
                        if (language_temp == "fr")
                        {
                            language = "Français";
                        }
                        break;

                    case "prefTemplate":
                        template = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefProject":
                        project = HttpContext.Current.Request.Form[thisKey];
                        break;

                    case "prefAllowSubmit":
                        string submit_value = HttpContext.Current.Request.Form[thisKey];
                        if (submit_value == "allowsubmit")
                        {
                            desire_to_upload = true;
                        }
                        break;

                    case "prefSendEmail":
                        string submit_value2 = HttpContext.Current.Request.Form[thisKey];
                        send_email_on_submission = submit_value2 == "sendemail";
                        break;

                    case "prefEmailStats":
                        string submit_value3 = HttpContext.Current.Request.Form[thisKey];
                        send_usages_emails = submit_value3 == "sendemail";
                        break;

                    case "prefRights":
                        default_rights = HttpContext.Current.Request.Form[thisKey];
                        break;
                    }
                }

                if (registration)
                {
                    if (username.Trim().Length == 0)
                    {
                        validationErrors.Add("Username is a required field");
                    }
                    else if (username.Trim().Length < 8)
                    {
                        validationErrors.Add("Username must be at least eight digits");
                    }
                    if ((password.Trim().Length == 0) || (password2.Trim().Length == 0))
                    {
                        validationErrors.Add("Select and confirm a password");
                    }
                    if (password.Trim() != password2.Trim())
                    {
                        validationErrors.Add("Passwords do not match");
                    }
                    else if (password.Length < 8)
                    {
                        validationErrors.Add("Password must be at least eight digits");
                    }
                    if (ufid.Trim().Length > 0)
                    {
                        if (ufid.Trim().Length != 8)
                        {
                            validationErrors.Add("UFIDs are always eight digits");
                        }
                        else
                        {
                            int ufid_convert_test;
                            if (!Int32.TryParse(ufid, out ufid_convert_test))
                            {
                                validationErrors.Add("UFIDs are always numeric");
                            }
                        }
                    }
                }

                // Validate the basic data is okay
                if (family_name.Trim().Length == 0)
                {
                    validationErrors.Add("Family name is a required field");
                }
                if (given_name.Trim().Length == 0)
                {
                    validationErrors.Add("Given name is a required field");
                }
                if ((email.Trim().Length == 0) || (email.IndexOf("@") < 0))
                {
                    validationErrors.Add("A valid email is required");
                }
                if (default_rights.Trim().Length > 1000)
                {
                    validationErrors.Add("Rights statement truncated to 1000 characters.");
                    default_rights = default_rights.Substring(0, 1000);
                }

                if ((registration) && (validationErrors.Count == 0))
                {
                    bool email_exists;
                    bool username_exists;
                    SobekCM_Database.UserName_Exists(username, email, out username_exists, out email_exists, Tracer);
                    if (email_exists)
                    {
                        validationErrors.Add("An account for that email address already exists.");
                    }
                    else if (username_exists)
                    {
                        validationErrors.Add("That username is taken.  Please choose another.");
                    }
                }

                if (validationErrors.Count == 0)
                {
                    user.College      = college.Trim();
                    user.Department   = department.Trim();
                    user.Email        = email.Trim();
                    user.Family_Name  = family_name.Trim();
                    user.Given_Name   = given_name.Trim();
                    user.Nickname     = nickname.Trim();
                    user.Organization = organization.Trim();
                    user.Unit         = unit.Trim();
                    user.Set_Default_Template(template.Trim());
                    // See if the project is different, if this is not registration
                    if ((!registration) && (user.Default_Metadata_Sets[0] != project.Trim()))
                    {
                        // Determine the in process directory for this
                        string user_in_process_directory = SobekCM_Library_Settings.In_Process_Submission_Location + "\\" + user.UserName;
                        if (user.ShibbID.Trim().Length > 0)
                        {
                            user_in_process_directory = SobekCM_Library_Settings.In_Process_Submission_Location + "\\" + user.ShibbID;
                        }
                        if (Directory.Exists(user_in_process_directory))
                        {
                            if (File.Exists(user_in_process_directory + "\\TEMP000001_00001.mets"))
                            {
                                File.Delete(user_in_process_directory + "\\TEMP000001_00001.mets");
                            }
                        }
                    }
                    user.Set_Current_Default_Metadata(project.Trim());
                    user.Preferred_Language       = language;
                    user.Default_Rights           = default_rights;
                    user.Send_Email_On_Submission = send_email_on_submission;
                    user.Receive_Stats_Emails     = send_usages_emails;

                    if (registration)
                    {
                        user.Can_Submit = false;
                        user.Send_Email_On_Submission = true;
                        user.ShibbID  = ufid;
                        user.UserName = username;
                        user.UserID   = -1;

                        // Save this new user
                        SobekCM_Database.Save_User(user, password, user.Authentication_Type, Tracer);

                        // Retrieve the user from the database
                        user = SobekCM_Database.Get_User(username, password, Tracer);

                        // Special code in case this is the very first user
                        if (user.UserID == 1)
                        {
                            // Add each template and project
                            DataSet       projectTemplateSet = SobekCM_Database.Get_All_Template_DefaultMetadatas(Tracer);
                            List <string> templates          = (from DataRow thisTemplate in projectTemplateSet.Tables[1].Rows select thisTemplate["TemplateCode"].ToString()).ToList();
                            List <string> projects           = (from DataRow thisProject in projectTemplateSet.Tables[0].Rows select thisProject["MetadataCode"].ToString()).ToList();

                            // Save the updates to this admin user
                            SobekCM_Database.Save_User(user, password, User_Authentication_Type_Enum.Sobek, Tracer);
                            SobekCM_Database.Update_SobekCM_User(user.UserID, true, true, true, true, true, true, true, "edit_internal", "editmarc_internal", true, true, true, Tracer);
                            SobekCM_Database.Update_SobekCM_User_DefaultMetadata(user.UserID, new ReadOnlyCollection <string>(projects), Tracer);
                            SobekCM_Database.Update_SobekCM_User_Templates(user.UserID, new ReadOnlyCollection <string>(templates), Tracer);

                            // Retrieve the user information again
                            user = SobekCM_Database.Get_User(username, password, Tracer);
                        }

                        user.Is_Just_Registered             = true;
                        HttpContext.Current.Session["user"] = user;

                        // If they want to be able to contribue, send an email
                        if (desire_to_upload)
                        {
                            SobekCM_Database.Send_Database_Email(SobekCM_Library_Settings.System_Email, "Submittal rights requested by " + user.Full_Name, "New user requested ability to submit new items.<br /><br /><blockquote>Name: " + user.Full_Name + "<br />Email: " + user.Email + "<br />Organization: " + user.Organization + "<br />User ID: " + user.UserID + "</blockquote>", true, false, -1, -1);
                        }

                        // Email the user their registation information
                        if (desire_to_upload)
                        {
                            SobekCM_Database.Send_Database_Email(email, "Welcome to " + mySobekText, "<strong>Thank you for registering for " + mySobekText + "</strong><br /><br />You can access this directly through the following link: <a href=\"" + currentMode.Base_URL + "/my\">" + currentMode.Base_URL + "/my</a><br /><br />Full Name: " + user.Full_Name + "<br />User Name: " + user.UserName + "<br /><br />You will receive an email when your request to submit items has been processed.", true, false, -1, -1);
                        }
                        else
                        {
                            SobekCM_Database.Send_Database_Email(email, "Welcome to " + mySobekText, "<strong>Thank you for registering for " + mySobekText + "</strong><br /><br />You can access this directly through the following link: <a href=\"" + currentMode.Base_URL + "/my\">" + currentMode.Base_URL + "/my</a><br /><br />Full Name: " + user.Full_Name + "<br />User Name: " + user.UserName, true, false, -1, -1);
                        }

                        // Now, forward back to the My Sobek home page
                        currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;

                        // If this is the first user to register (who would have been set to admin), send to the
                        // system-wide settings screen
                        if (user.UserID == 1)
                        {
                            currentMode.Mode       = Display_Mode_Enum.Administrative;
                            currentMode.Admin_Type = Admin_Type_Enum.Settings;
                        }
                        currentMode.Redirect();
                    }
                    else
                    {
                        HttpContext.Current.Session["user"] = user;
                        SobekCM_Database.Save_User(user, String.Empty, user.Authentication_Type, Tracer);

                        // Now, forward back to the My Sobek home page
                        currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                        currentMode.Redirect();
                    }
                }
            }
            else
            {
                family_name              = user.Family_Name;
                given_name               = user.Given_Name;
                nickname                 = user.Nickname;
                email                    = user.Email;
                organization             = user.Organization;
                college                  = user.College;
                department               = user.Department;
                unit                     = user.Unit;
                username                 = user.UserName;
                ufid                     = user.ShibbID;
                language                 = user.Preferred_Language;
                send_email_on_submission = user.Send_Email_On_Submission;
                default_rights           = user.Default_Rights;
            }
        }
コード例 #17
0
        /// <summary> Constructor for a new instance of the Wordmarks_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> Postback from editing an existing wordmark, deleting a wordmark, or creating a new wordmark is handled here in the constructor </remarks>
        public Wordmarks_AdminViewer(User_Object User, SobekCM_Navigation_Object Current_Mode, Custom_Tracer Tracer) : base(User)
        {
            Tracer.Add_Trace("Wordmarks_AdminViewer.Constructor", String.Empty);

            // Save the mode and settings  here
            currentMode = Current_Mode;

            // Set action message to nothing to start
            actionMessage = String.Empty;

            // If the user cannot edit this, go back
            if ((user == null) || ((!user.Is_System_Admin) && (!user.Is_Portal_Admin)))
            {
                currentMode.Mode          = Display_Mode_Enum.My_Sobek;
                currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                currentMode.Redirect();
                return;
            }

            // Get the wordmark directory and ensure it exists
            wordmarkDirectory = HttpContext.Current.Server.MapPath("design/wordmarks");
            if (!Directory.Exists(wordmarkDirectory))
            {
                Directory.CreateDirectory(wordmarkDirectory);
            }

            // Get the list of all wordmarks
            wordmarks = new Dictionary <string, Wordmark_Icon>();
            SobekCM_Database.Populate_Icon_List(wordmarks, Tracer);

            // If this is a postback, handle any events first
            // if (currentMode.isPostBack)
            // {
            try
            {
                // Pull the standard values
                NameValueCollection form = HttpContext.Current.Request.Form;
                if (form["admin_wordmark_code_delete"] != null)
                {
                    string delete_value      = form["admin_wordmark_code_delete"].ToUpper().Trim();
                    string save_value        = form["admin_wordmark_code_tosave"].ToUpper().Trim();
                    string new_wordmark_code = form["admin_wordmark_code"].ToUpper().Trim();

                    // Was this a reset request?
                    if (delete_value.Length > 0)
                    {
                        // If the value to delete does not have a period, then it has no extension,
                        // so this is to delete a USED wordmark which is both a file AND in the database
                        if (delete_value.IndexOf(".") < 0)
                        {
                            Tracer.Add_Trace("Wordmarks_AdminViewer.Constructor", "Delete wordmark '" + delete_value + "' from the database");

                            // Get the wordmark, so we can also delete the file
                            Wordmark_Icon deleteIcon = wordmarks[delete_value];

                            // Delete from the database
                            if (SobekCM_Database.Delete_Icon(delete_value, Tracer))
                            {
                                // Set the deleted wordmark message
                                actionMessage = "Deleted wordmark <i>" + delete_value + "</i>";

                                // Try to delete the file related to this wordmark now
                                if ((deleteIcon != null) && (File.Exists(wordmarkDirectory + "\\" + deleteIcon.Image_FileName)))
                                {
                                    try
                                    {
                                        File.Delete(wordmarkDirectory + "\\" + deleteIcon.Image_FileName);
                                    }
                                    catch (Exception)
                                    {
                                        actionMessage = "Deleted wordmark <i>" + delete_value + "</i> but unable to delete the file <i>" + deleteIcon.Image_FileName + "</i>";
                                    }
                                }

                                // Repull the wordmark list now
                                wordmarks = new Dictionary <string, Wordmark_Icon>();
                                SobekCM_Database.Populate_Icon_List(wordmarks, Tracer);
                            }
                            else
                            {
                                // Report the error
                                if (SobekCM_Database.Last_Exception == null)
                                {
                                    actionMessage = "Unable to delete wordmark <i>" + delete_value + "</i> since it is in use";
                                }
                                else
                                {
                                    actionMessage = "Unknown error while deleting wordmark <i>" + delete_value + "</i>";
                                }
                            }
                        }
                        else
                        {
                            // This is to delete just a file, which presumably is unused by the system
                            // and does not appear in the database
                            // Try to delete the file related to this wordmark now
                            if (File.Exists(wordmarkDirectory + "\\" + delete_value))
                            {
                                try
                                {
                                    File.Delete(wordmarkDirectory + "\\" + delete_value);
                                    actionMessage = "Deleted unused image file <i>" + delete_value + "</i>";
                                }
                                catch (Exception)
                                {
                                    actionMessage = "Unable to delete unused image <i>" + delete_value + "</i>";
                                }
                            }
                        }
                    }
                    else
                    {
                        // Or.. was this a save request
                        if (save_value.Length > 0)
                        {
                            Tracer.Add_Trace("Wordmarks_AdminViewer.Constructor", "Save wordmark '" + save_value + "'");

                            // Was this to save a new interface (from the main page) or edit an existing (from the popup form)?
                            if (save_value == new_wordmark_code)
                            {
                                string new_file  = form["admin_wordmark_file"].Trim();
                                string new_link  = form["admin_wordmark_link"].Trim();
                                string new_title = form["admin_wordmark_title"].Trim();

                                // Save this new wordmark
                                if (SobekCM_Database.Save_Icon(new_wordmark_code, new_file, new_link, new_title, Tracer) > 0)
                                {
                                    actionMessage = "Saved new wordmark <i>" + save_value + "</i>";
                                }
                                else
                                {
                                    actionMessage = "Unable to save new wordmark <i>" + save_value + "</i>";
                                }
                            }
                            else
                            {
                                string edit_file  = form["form_wordmark_file"].Trim();
                                string edit_link  = form["form_wordmark_link"].Trim();
                                string edit_title = form["form_wordmark_title"].Trim();

                                // Save this existing wordmark
                                if (SobekCM_Database.Save_Icon(save_value, edit_file, edit_link, edit_title, Tracer) > 0)
                                {
                                    actionMessage = "Edited existing wordmark <i>" + save_value + "</i>";
                                }
                                else
                                {
                                    actionMessage = "Unable to edit existing wordmark <i>" + save_value + "</i>";
                                }
                            }

                            // Repull the wordmark list now
                            wordmarks = new Dictionary <string, Wordmark_Icon>();
                            SobekCM_Database.Populate_Icon_List(wordmarks, Tracer);
                        }
                    }
                }
            }
            catch (Exception)
            {
                actionMessage = "Unknown error caught while handing request.";
            }
            //}

            // Get the list of wordmarks in the directory
            string[] allFiles = SobekCM_File_Utilities.GetFiles(wordmarkDirectory, "*.jpg|*.jpeg|*.png|*.gif|*.bmp");
            loweredFiles = allFiles.Select(ThisFileName => new FileInfo(ThisFileName)).Select(ThisFileInfo => ThisFileInfo.Name.ToLower()).ToList();
            loweredFiles.Sort();

            // Get the list of all assigned wordmark files
            foreach (Wordmark_Icon thisWordmark in wordmarks.Values)
            {
                if (loweredFiles.Contains(thisWordmark.Image_FileName.ToLower()))
                {
                    loweredFiles.Remove(thisWordmark.Image_FileName.ToLower());
                }
            }
        }
        /// <summary> Constructor for a new instance of the Aggregations_Mgmt_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="CurrentMode"> Mode / navigation information for the current request</param>
        /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param>
        /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param>       
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> Postback from handling an edit or new aggregation is handled here in the constructor </remarks>
        public Aggregations_Mgmt_AdminViewer(User_Object User, SobekCM_Navigation_Object CurrentMode, Aggregation_Code_Manager Code_Manager, List<Thematic_Heading> Thematic_Headings, Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Aggregations_Mgmt_AdminViewer.Constructor", String.Empty);

            codeManager = Code_Manager;
            currentMode = CurrentMode;
            thematicHeadings = Thematic_Headings;

            // Set some defaults
            actionMessage = String.Empty;
            enteredCode = String.Empty;
            enteredParent = String.Empty;
            enteredType = String.Empty;
            enteredShortname = String.Empty;
            enteredName = String.Empty;
            enteredDescription = String.Empty;
            enteredIsActive = false;
            enteredIsHidden = false;

            // If the user cannot edit this, go back
            if (( user == null ) || ((!user.Is_System_Admin) && ( !user.Is_Portal_Admin )))
            {
                currentMode.Mode = Display_Mode_Enum.My_Sobek;
                currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                currentMode.Redirect();
                return;
            }

            // If this is a postback, handle any events first
            if (currentMode.isPostBack)
            {
                try
                {
                    // Pull the standard values
                    NameValueCollection form = HttpContext.Current.Request.Form;

                    string save_value = form["admin_aggr_tosave"].ToUpper().Trim();
                    string new_aggregation_code = String.Empty;
                    if ( form["admin_aggr_code"] != null )
                        new_aggregation_code = form["admin_aggr_code"].ToUpper().Trim();

                    // Check for reset request as well
                    string reset_aggregation_code = String.Empty;
                    if (form["admin_aggr_reset"] != null)
                        reset_aggregation_code = form["admin_aggr_reset"].ToLower().Trim();

                    string delete_aggregation_code = String.Empty;
                    if (form["admin_aggr_delete"] != null)
                        delete_aggregation_code = form["admin_aggr_delete"].ToLower().Trim();

                    // Was this to delete the aggregation?
                    if ( delete_aggregation_code.Length > 0)
                    {
                        string delete_error;
                        int errorCode = SobekCM_Database.Delete_Item_Aggregation(delete_aggregation_code, user.Is_System_Admin, user.Full_Name, Tracer, out delete_error);
                        if (errorCode <= 0)
                        {
                            string delete_folder = SobekCM_Library_Settings.Base_Design_Location + "aggregations\\" + delete_aggregation_code;
                            if (SobekCM_File_Utilities.Delete_Folders_Recursively(delete_folder))
                                actionMessage = "Deleted '" + delete_aggregation_code + "' aggregation<br /><br />Unable to remove aggregation directory<br /><br />Some of the files may be in use";
                            else
                                actionMessage = "Deleted '" + delete_aggregation_code + "' aggregation";
                        }
                        else
                        {
                            actionMessage = delete_error;
                        }

                        // Reload the list of all codes, to include this new one and the new hierarchy
                        lock (codeManager)
                        {
                            SobekCM_Database.Populate_Code_Manager(codeManager, Tracer);
                        }
                    }

                    // If there is a reset request here, purge the aggregation from the cache
                    if (reset_aggregation_code.Length > 0)
                    {
                        Cached_Data_Manager.Remove_Item_Aggregation(reset_aggregation_code, Tracer);
                    }

                    // If there was a save value continue to pull the rest of the data
                    if (save_value.Length > 0)
                    {

                        bool is_active = false;
                        bool is_hidden = true;

                        // Was this to save a new aggregation (from the main page) or edit an existing (from the popup form)?
                        if (save_value == new_aggregation_code)
                        {

                            // Pull the values from the submitted form
                            string new_type = form["admin_aggr_type"];
                            string new_parent = form["admin_aggr_parent"].Trim();
                            string new_name = form["admin_aggr_name"].Trim();
                            string new_shortname = form["admin_aggr_shortname"].Trim();
                            string new_description = form["admin_aggr_desc"].Trim();
                            string new_link = form["admin_aggr_link"].Trim();

                            object temp_object = form["admin_aggr_isactive"];
                            if (temp_object != null)
                            {
                                is_active = true;
                            }

                            temp_object = form["admin_aggr_ishidden"];
                            if (temp_object != null)
                            {
                                is_hidden = false;
                            }

                            // Convert to the integer id for the parent and begin to do checking
                            List<string> errors = new List<string>();
                            int parentid = -1;
                            if (new_parent.Length > 0)
                            {
                                try
                                {
                                    parentid = Convert.ToInt32(new_parent);
                                }
                                catch
                                {
                                    errors.Add("Invalid parent id selected!");
                                }
                            }
                            else
                            {
                                errors.Add("You must select a PARENT for this new aggregation");
                            }

                            // Validate the code
                            if (new_aggregation_code.Length > 20)
                            {
                                errors.Add("New aggregation code must be twenty characters long or less");
                            }
                            else if (new_aggregation_code.Length == 0)
                            {
                                errors.Add("You must enter a CODE for this item aggregation");

                            }
                            else if (codeManager[new_aggregation_code.ToUpper()] != null)
                            {
                                errors.Add("New code must be unique... <i>" + new_aggregation_code + "</i> already exists");
                            }
                            else if (SobekCM_Library_Settings.Reserved_Keywords.Contains(new_aggregation_code.ToLower()))
                            {
                                errors.Add("That code is a system-reserved keyword.  Try a different code.");
                            }

                            // Was there a type and name
                            if (new_type.Length == 0)
                            {
                                errors.Add("You must select a TYPE for this new aggregation");
                            }
                            if (new_description.Length == 0)
                            {
                                errors.Add("You must enter a DESCRIPTION for this new aggregation");
                            }
                            if (new_name.Length == 0)
                            {
                                errors.Add("You must enter a NAME for this new aggregation");
                            }
                            else
                            {
                                if (new_shortname.Length == 0)
                                    new_shortname = new_name;
                            }

                            if (errors.Count > 0)
                            {
                                // Create the error message
                                actionMessage = "ERROR: Invalid entry for new item aggregation<br />";
                                foreach (string error in errors)
                                    actionMessage = actionMessage + "<br />" + error;

                                // Save all the values that were entered
                                enteredCode = new_aggregation_code;
                                enteredDescription = new_description;
                                enteredIsActive = is_active;
                                enteredIsHidden = is_hidden;
                                enteredName = new_name;
                                enteredParent = new_parent;
                                enteredShortname = new_shortname;
                                enteredType = new_type;
                                enteredLink = new_link;
                            }
                            else
                            {
                                // Get the correct type
                                string correct_type = "Collection";
                                switch (new_type)
                                {
                                    case "coll":
                                        correct_type = "Collection";
                                        break;

                                    case "group":
                                        correct_type = "Collection Group";
                                        break;

                                    case "subcoll":
                                        correct_type = "SubCollection";
                                        break;

                                    case "inst":
                                        correct_type = "Institution";
                                        break;

                                    case "exhibit":
                                        correct_type = "Exhibit";
                                        break;

                                    case "subinst":
                                        correct_type = "Institutional Division";
                                        break;
                                }
                                // Make sure inst and subinst start with 'i'
                                if (new_type.IndexOf("inst") >= 0)
                                {
                                    if (new_aggregation_code[0] == 'I')
                                        new_aggregation_code = "i" + new_aggregation_code.Substring(1);
                                    if (new_aggregation_code[0] != 'i')
                                        new_aggregation_code = "i" + new_aggregation_code;
                                }

                                // Get the thematic heading id (no checks here)
                                int thematicHeadingId = -1;
                                if (form["admin_aggr_heading"] != null)
                                    thematicHeadingId = Convert.ToInt32(form["admin_aggr_heading"]);

                                // Try to save the new item aggregation
                                if (SobekCM_Database.Save_Item_Aggregation(new_aggregation_code, new_name, new_shortname, new_description, thematicHeadingId, correct_type, is_active, is_hidden, new_link, parentid, user.Full_Name, Tracer))
                                {
                                    // Ensure a folder exists for this, otherwise create one
                                    try
                                    {
                                        string folder = SobekCM_Library_Settings.Base_Design_Location + "aggregations\\" + new_aggregation_code.ToLower();
                                        if (!Directory.Exists(folder))
                                        {
                                            // Create this directory and all the subdirectories
                                            Directory.CreateDirectory(folder);
                                            Directory.CreateDirectory(folder + "/html");
                                            Directory.CreateDirectory(folder + "/images");
                                            Directory.CreateDirectory(folder + "/html/home");
                                            Directory.CreateDirectory(folder + "/images/buttons");
                                            Directory.CreateDirectory(folder + "/images/banners");

                                            // Create a default home text file
                                            StreamWriter writer = new StreamWriter(folder + "/html/home/text.html");
                                            writer.WriteLine("<br />New collection home page text goes here.<br /><br />To edit this, log on as the aggregation admin and hover over this text to edit it.<br /><br />");
                                            writer.Flush();
                                            writer.Close();

                                            // Copy the default banner and buttons from images
                                            if (File.Exists(SobekCM_Library_Settings.Base_Directory + "default/images/default_button.png"))
                                                File.Copy(SobekCM_Library_Settings.Base_Directory + "default/images/default_button.png", folder + "/images/buttons/coll.png");
                                            if (File.Exists(SobekCM_Library_Settings.Base_Directory + "default/images/default_button.gif"))
                                                File.Copy(SobekCM_Library_Settings.Base_Directory + "default/images/default_button.gif", folder + "/images/buttons/coll.gif");

                                            // Try to create a new custom banner
                                            bool custom_banner_created = false;
                                            // Create the banner with the name of the collection
                                            if (Directory.Exists(SobekCM_Library_Settings.Application_Server_Network + "\\default\\banner_images"))
                                            {
                                                try
                                                {
                                                    string[] banners = Directory.GetFiles(SobekCM_Library_Settings.Application_Server_Network + "\\default\\banner_images", "*.jpg");
                                                    if (banners.Length > 0)
                                                    {
                                                        Random randomizer = new Random();
                                                        string banner_to_use = banners[randomizer.Next(0, banners.Length - 1)];
                                                        Bitmap bitmap = (Bitmap)System.Drawing.Bitmap.FromFile(banner_to_use);

                                                        RectangleF rectf = new RectangleF(30, bitmap.Height - 55, bitmap.Width - 40, 40);
                                                        Graphics g = Graphics.FromImage(bitmap);
                                                        g.SmoothingMode = SmoothingMode.AntiAlias;
                                                        g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                                                        g.PixelOffsetMode = PixelOffsetMode.HighQuality;
                                                        g.DrawString(new_name, new Font("Tahoma", 25, FontStyle.Bold), Brushes.Black, rectf);
                                                        g.Flush();

                                                        string new_file = folder + "/images/banners/coll.jpg";
                                                        if (!File.Exists(new_file))
                                                        {
                                                            bitmap.Save(new_file, ImageFormat.Jpeg);
                                                            custom_banner_created = true;
                                                        }
                                                    }
                                                }
                                                catch (Exception ee)
                                                {
                                                    string msg = ee.Message;
                                                }
                                            }

                                            if ((!custom_banner_created) && (!File.Exists(folder + "/images/banners/coll.jpg")))
                                            {
                                                if (File.Exists(SobekCM_Library_Settings.Base_Directory + "default/images/default_banner.jpg"))
                                                    File.Copy(SobekCM_Library_Settings.Base_Directory + "default/images/default_banner.jpg", folder + "/images/banners/coll.jpg");
                                            }

                                            // Now, try to create the item aggregation and write the configuration file
                                            Item_Aggregation itemAggregation = Item_Aggregation_Builder.Get_Item_Aggregation(new_aggregation_code, String.Empty, null, false, false, Tracer);
                                            itemAggregation.Write_Configuration_File(SobekCM_Library_Settings.Base_Design_Location + itemAggregation.ObjDirectory);
                                        }
                                    }
                                    catch
                                    {
                                        actionMessage = "ERROR saving the new item aggregation to the database";
                                    }

                                    // Reload the list of all codes, to include this new one and the new hierarchy
                                    lock (codeManager)
                                    {
                                        SobekCM_Database.Populate_Code_Manager(codeManager, Tracer);
                                    }
                                    if ( !String.IsNullOrEmpty(actionMessage))
                                        actionMessage = "New item aggregation <i>" + new_aggregation_code + "</i> saved successfully";
                                }
                                else
                                {
                                    actionMessage = "ERROR saving the new item aggregation to the database";
                                }
                            }
                        }
                    }
                }
                catch
                {
                    actionMessage = "General error while reading postback information";
                }
            }
        }
コード例 #19
0
        /// <summary> Constructor for a new instance of the Admin_HtmlSubwriter class </summary>
        /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param>
        /// <param name="All_Items_Lookup"> Lookup object used to pull basic information about any item loaded into this library </param>
        /// <param name="Hierarchy_Object"> Current item aggregation object to display </param>
        /// <param name="HTML_Skin"> HTML Web skin which controls the overall appearance of this digital library </param>
        /// <param name="Translator"> Language support object which handles simple translational duties </param>
        /// <param name="Current_Mode"> Mode / navigation information for the current request</param>
        /// <param name="Aggregation_Aliases"> List of all existing aliases for existing aggregations </param>
        /// <param name="Web_Skin_Collection"> Collection of all the web skins </param>
        /// <param name="Current_User"> Currently logged on user </param>
        /// <param name="Icon_Table"> Dictionary of all the wordmark/icons which can be tagged to the items </param>
        /// <param name="IP_Restrictions"> List of all IP Restriction ranges in use by this digital library </param>
        /// <param name="URL_Portals"> List of all web portals into this system </param>
        /// <param name="Thematic_Headings"> Headings under which all the highlighted collections on the home page are organized </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering </param>
        public Admin_HtmlSubwriter(Aggregation_Code_Manager Code_Manager,
                                   Item_Lookup_Object All_Items_Lookup,
                                   Item_Aggregation Hierarchy_Object,
                                   SobekCM_Skin_Object HTML_Skin,
                                   Language_Support_Info Translator,
                                   SobekCM_Navigation_Object Current_Mode,
                                   Dictionary <string, string> Aggregation_Aliases,
                                   SobekCM_Skin_Collection Web_Skin_Collection,
                                   User_Object Current_User,
                                   IP_Restriction_Ranges IP_Restrictions,
                                   Dictionary <string, Wordmark_Icon> Icon_Table,
                                   Portal_List URL_Portals,
                                   List <Thematic_Heading> Thematic_Headings,
                                   Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Saving values and geting user object back from the session");

            codeManager       = Code_Manager;
            itemList          = All_Items_Lookup;
            htmlSkin          = HTML_Skin;
            translator        = Translator;
            currentCollection = Hierarchy_Object;
            user           = Current_User;
            ipRestrictions = IP_Restrictions;
            iconTable      = Icon_Table;


            // All Admin pages require a user being logged on
            if (Current_User == null)
            {
                Current_Mode.Mode             = Display_Mode_Enum.My_Sobek;
                Current_Mode.My_Sobek_Type    = My_Sobek_Type_Enum.Logon;
                Current_Mode.My_Sobek_SubMode = String.Empty;
                Current_Mode.Redirect();
                return;
            }

            // If the user is not an admin, and admin was selected, reroute this
            if ((!Current_User.Is_System_Admin) && (!Current_User.Is_Portal_Admin) && (Current_Mode.Admin_Type != Admin_Type_Enum.Aggregation_Single))
            {
                Current_Mode.Mode             = Display_Mode_Enum.My_Sobek;
                Current_Mode.My_Sobek_Type    = My_Sobek_Type_Enum.Home;
                Current_Mode.My_Sobek_SubMode = String.Empty;
                Current_Mode.Redirect();
                return;
            }

            Tracer.Add_Trace("Admin_HtmlSubwriter.Constructor", "Building the my sobek viewer object");
            switch (Current_Mode.Admin_Type)
            {
            case Admin_Type_Enum.Aggregation_Single:
                adminViewer = new Aggregation_Single_AdminViewer(user, Current_Mode, codeManager, Thematic_Headings, Web_Skin_Collection, Tracer);
                break;

            case Admin_Type_Enum.Home:
                adminViewer = new Home_AdminViewer(user, Current_Mode, Tracer);
                break;

            case Admin_Type_Enum.Builder_Status:
                adminViewer = new Builder_AdminViewer(user, Current_Mode);
                break;

            case Admin_Type_Enum.Skins:
                adminViewer = new Skins_AdminViewer(user, Current_Mode, Web_Skin_Collection, Tracer);
                break;

            case Admin_Type_Enum.Aliases:
                adminViewer = new Aliases_AdminViewer(user, Current_Mode, Aggregation_Aliases, Code_Manager, Tracer);
                break;

            case Admin_Type_Enum.Wordmarks:
                adminViewer = new Wordmarks_AdminViewer(user, Current_Mode, Tracer);
                break;

            case Admin_Type_Enum.URL_Portals:
                adminViewer = new Portals_AdminViewer(user, Current_Mode, URL_Portals, Web_Skin_Collection, Tracer);
                break;

            case Admin_Type_Enum.Users:
                adminViewer = new Users_AdminViewer(user, Current_Mode, codeManager, Tracer);
                break;

            case Admin_Type_Enum.User_Groups:
                adminViewer = new User_Group_AdminViewer(user, Current_Mode, codeManager, Tracer);
                break;

            case Admin_Type_Enum.Aggregations_Mgmt:
                adminViewer = new Aggregations_Mgmt_AdminViewer(user, Current_Mode, codeManager, Thematic_Headings, Tracer);
                break;

            case Admin_Type_Enum.IP_Restrictions:
                adminViewer = new IP_Restrictions_AdminViewer(user, Current_Mode, ipRestrictions, Tracer);
                break;

            case Admin_Type_Enum.Thematic_Headings:
                adminViewer = new Thematic_Headings_AdminViewer(user, Current_Mode, Thematic_Headings, codeManager, Tracer);
                break;

            case Admin_Type_Enum.Settings:
                adminViewer = new Settings_AdminViewer(user, Current_Mode, Tracer);
                break;

            case Admin_Type_Enum.Default_Metadata:
                if (Current_Mode.My_Sobek_SubMode.Length > 1)
                {
                    string project_code = Current_Mode.My_Sobek_SubMode.Substring(1);
                    Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Checking cache for valid project file");
                    if (user != null)
                    {
                        SobekCM_Item projectObject = Cached_Data_Manager.Retrieve_Project(user.UserID, project_code, Tracer);
                        if (projectObject != null)
                        {
                            Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Valid default metadata set found in cache");
                            adminViewer = new Edit_Item_Metadata_MySobekViewer(user, Current_Mode, itemList, projectObject, codeManager, iconTable, htmlSkin, null, null, Tracer);
                        }
                        else
                        {
                            if (SobekCM_Database.Get_All_Template_DefaultMetadatas(Tracer).Tables[0].Select("MetadataCode='" + project_code + "'").Length > 0)
                            {
                                Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Building default metadata set from (possible) PMETS");
                                string       pmets_file = SobekCM_Library_Settings.Base_MySobek_Directory + "projects\\" + Current_Mode.My_Sobek_SubMode.Substring(1) + ".pmets";
                                SobekCM_Item pmets_item = File.Exists(pmets_file) ? SobekCM_Item.Read_METS(pmets_file) : new SobekCM_Item();
                                pmets_item.Bib_Info.Main_Title.Title = "Default metadata set for '" + project_code + "'";
                                pmets_item.Bib_Info.SobekCM_Type     = TypeOfResource_SobekCM_Enum.Project;
                                pmets_item.BibID            = project_code.ToUpper();
                                pmets_item.VID              = "00001";
                                pmets_item.Source_Directory = SobekCM_Library_Settings.Base_MySobek_Directory + "projects\\";

                                Tracer.Add_Trace("MySobek_HtmlSubwriter.Constructor", "Adding project file to cache");

                                Cached_Data_Manager.Store_Project(user.UserID, project_code, pmets_item, Tracer);

                                adminViewer = new Edit_Item_Metadata_MySobekViewer(user, Current_Mode, itemList, pmets_item, codeManager, iconTable, htmlSkin, null, null, Tracer);
                            }
                        }
                    }
                }


                if (adminViewer == null)
                {
                    adminViewer = new Default_Metadata_AdminViewer(user, Current_Mode, Tracer);
                }
                break;
            }

            // Pass in the navigation and translator information
            adminViewer.CurrentMode = Current_Mode;
            adminViewer.Translator  = translator;
        }
コード例 #20
0
        /// <summary> Constructor for a new instance of the Aliases_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="CurrentMode"> Mode / navigation information for the current request</param>
        /// <param name="Aggregation_Aliases"> Dictionary of all current item aggregation aliases </param>
        /// <param name="Code_Manager"> List of valid collection codes, including mapping from the Sobek collections to Greenstone collections</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> Postback from handling an edit or new item aggregation alias is handled here in the constructor </remarks>
        public Aliases_AdminViewer(User_Object User, SobekCM_Navigation_Object CurrentMode, Dictionary <string, string> Aggregation_Aliases, Aggregation_Code_Manager Code_Manager, Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Aliases_AdminViewer.Constructor", String.Empty);

            // Save the mode and settings  here
            currentMode        = CurrentMode;
            aggregationAliases = Aggregation_Aliases;

            // Set action message to nothing to start
            actionMessage = String.Empty;

            // If the user cannot edit this, go back
            if ((user == null) || ((!user.Is_System_Admin) && (!user.Is_Portal_Admin)))
            {
                CurrentMode.Mode          = Display_Mode_Enum.My_Sobek;
                CurrentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                CurrentMode.Redirect();
                return;
            }

            // If this is a postback, handle any events first
            if (CurrentMode.isPostBack)
            {
                try
                {
                    // Pull the standard values
                    NameValueCollection form = HttpContext.Current.Request.Form;

                    string save_value = form["admin_forwarding_tosave"].ToLower().Trim();
                    string new_alias  = form["admin_forwarding_alias"].ToLower().Trim();

                    // Was this a save request
                    if (save_value.Length > 0)
                    {
                        // If this starts with a '-' this is a delete
                        if (save_value[0] == '-')
                        {
                            if ((user.Is_System_Admin) && (save_value.Length > 1))
                            {
                                save_value = save_value.Substring(1);
                                Tracer.Add_Trace("Aliases_AdminViewer.Constructor", "Delete alias '" + save_value + "'");
                                if (SobekCM_Database.Delete_Aggregation_Alias(save_value, Tracer))
                                {
                                    if (aggregationAliases.ContainsKey(save_value))
                                    {
                                        aggregationAliases.Remove(save_value);
                                    }

                                    actionMessage = "Deleted existing aggregation alias <i>" + save_value + "</i>";
                                }
                            }
                        }
                        else
                        {
                            Tracer.Add_Trace("Aliases_AdminViewer.Constructor", "Save alias '" + save_value + "'");

                            // Was this to save a new alias (from the main page) or edit an existing (from the popup form)?
                            if (save_value == new_alias)
                            {
                                string new_code = form["admin_forwarding_code"].ToLower().Trim();

                                // Validate the code
                                if (new_code.Length > 20)
                                {
                                    actionMessage = "New alias code must be twenty characters long or less";
                                }
                                else if (new_code.Length == 0)
                                {
                                    actionMessage = "You must enter a CODE for this aggregation alias";
                                }
                                else if (Code_Manager[new_code.ToUpper()] != null)
                                {
                                    actionMessage = "Aggregation with this code already exists";
                                }
                                else if (SobekCM_Library_Settings.Reserved_Keywords.Contains(new_code.ToLower()))
                                {
                                    actionMessage = "That code is a system-reserved keyword.  Try a different code.";
                                }

                                // Save this new forwarding
                                if (SobekCM_Database.Save_Aggregation_Alias(save_value, new_code, Tracer))
                                {
                                    if (aggregationAliases.ContainsKey(save_value))
                                    {
                                        aggregationAliases[save_value] = new_code;
                                    }
                                    else
                                    {
                                        aggregationAliases.Add(save_value, new_code);
                                    }

                                    actionMessage = "Saved new aggregation alias <i>" + save_value + "</i>";
                                }
                                else
                                {
                                    actionMessage = "Unable to save new aggregation alias <i>" + save_value + "</i>";
                                }
                            }
                            else
                            {
                                string edit_code = form["form_forwarding_code"].ToLower().Trim();

                                // Save this existing forwarding
                                if (SobekCM_Database.Save_Aggregation_Alias(save_value, edit_code, Tracer))
                                {
                                    if (aggregationAliases.ContainsKey(save_value))
                                    {
                                        aggregationAliases[save_value] = edit_code;
                                    }
                                    else
                                    {
                                        aggregationAliases.Add(save_value, edit_code);
                                    }

                                    actionMessage = "Edited existing aggregation alias <i>" + save_value + "</i>";
                                }
                                else
                                {
                                    actionMessage = "Unable to save existing aggregation alias <i>" + save_value + "</i>";
                                }
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    actionMessage = "Unknown error caught while processing request";
                }
            }
        }
コード例 #21
0
        /// <summary> Constructor for a new instance of the Default_Metadata_AdminViewer class </summary>
        /// <param name="User"> Authenticated user information </param>
        /// <param name="CurrentMode"> Mode / navigation information for the current request</param>
        /// <param name="Tracer">Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> Postback from handling a new project is handled here in the constructor </remarks>
        public Default_Metadata_AdminViewer(User_Object User, SobekCM_Navigation_Object CurrentMode, Custom_Tracer Tracer)
            : base(User)
        {
            Tracer.Add_Trace("Default_Metadata_AdminViewer.Constructor", String.Empty);

            // Save the mode and settings  here
            currentMode = CurrentMode;

            // Set action message to nothing to start
            actionMessage = String.Empty;

            // If the user cannot edit this, go back
            if ((!user.Is_System_Admin) && (!user.Is_Portal_Admin))
            {
                currentMode.Mode          = Display_Mode_Enum.My_Sobek;
                currentMode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                currentMode.Redirect();
                return;
            }

            // If this is a postback, handle any events first
            if (currentMode.isPostBack)
            {
                try
                {
                    // Pull the standard values
                    NameValueCollection form = HttpContext.Current.Request.Form;

                    string save_value   = form["admin_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 ((user.Is_System_Admin) && (delete_value.Length > 0))
                    {
                        Tracer.Add_Trace("Default_Metadata_AdminViewer.Constructor", "Delete default metadata '" + delete_value + "'");

                        // Try to delete in the database
                        if (SobekCM_Database.Delete_Project(delete_value, Tracer))
                        {
                            // Set the message
                            actionMessage = "Deletes default metadata '" + delete_value + "'";

                            // Look for the file to delete as well
                            string pmets_file = SobekCM_Library_Settings.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";
                        }
                    }
                    else if (save_value.Length > 0)                     // Or.. was this a save request
                    {
                        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)
                        {
                            string new_base_code = form["admin_project_base"].ToUpper().Trim();
                            string new_name      = form["admin_project_name"].Trim();

                            // Save this new interface
                            if (SobekCM_Database.Save_Default_Metadata(save_value.ToUpper(), new_name, Tracer))
                            {
                                actionMessage = "Saved new default metadata <i>" + save_value + "</i>";
                            }
                            else
                            {
                                actionMessage = "Unable to save new default metadata <i>" + save_value + "</i>";
                            }

                            // Try to creating the PMETS file if there was a base PMETS code provided
                            try
                            {
                                if (new_base_code.Length > 0)
                                {
                                    string pmets_file      = SobekCM_Library_Settings.Base_MySobek_Directory + "projects\\" + code_value + ".pmets";
                                    string base_pmets_file = SobekCM_Library_Settings.Base_MySobek_Directory + "projects\\" + new_base_code + ".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();

                            // Save this existing interface
                            if (SobekCM_Database.Save_Default_Metadata(save_value.ToUpper(), edit_name, Tracer))
                            {
                                actionMessage = "Renamed existing default metadata <i>" + save_value + "</i>";
                            }
                            else
                            {
                                actionMessage = "Unable to rename existing default metadata <i>" + save_value + "</i>";
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    actionMessage = "Unknown exception occurred while processing your request";
                }
            }
        }