Esempio n. 1
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;
        }
        /// <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;
            }
        }
Esempio n. 3
0
        /// <summary> This is an opportunity to write HTML directly into the main form, without
        /// using the pop-up html form architecture </summary>
        /// <param name="Output"> Textwriter to write the pop-up form HTML for this viewer </param>
        /// <param name="Tracer"> Trace object keeps a list of each method executed and important milestones in rendering</param>
        /// <remarks> This text will appear within the ItemNavForm form tags </remarks>
        public override void Write_ItemNavForm_Closing(TextWriter Output, Custom_Tracer Tracer)
        {
            Tracer.Add_Trace("Default_Metadata_AdminViewer.Write_ItemNavForm_Closing", "Add any popup divisions for form elements");

            Output.WriteLine("<!-- Default_Metadata_AdminViewer.Write_ItemNavForm_Closing -->");

            // Add the scripts needed
            Output.WriteLine("<script type=\"text/javascript\" src=\"" + currentMode.Base_URL + "default/scripts/jquery/jquery-ui-1.10.3.custom.min.js\"></script>");

            // Add the hidden field
            Output.WriteLine("<!-- Hidden field is used for postbacks to indicate what to save -->");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_project_tosave\" name=\"admin_project_tosave\" value=\"\" />");
            Output.WriteLine("<input type=\"hidden\" id=\"admin_project_delete\" name=\"admin_project_delete\" value=\"\" />");
            Output.WriteLine();

            Output.WriteLine("<!-- Default_Metadata Rename Form -->");
            Output.WriteLine("<div class=\"sbkPav_PopupDiv\" id=\"form_project\" style=\"display:none;\">");
            Output.WriteLine("  <div class=\"sbkAdm_PopupTitle\"><table style=\"width:100%\"><tr><td style=\"text-align:left;\">RENAME DEFAULT METADATA</td><td style=\"text-align:right;\"> <a href=\"#template\" alt=\"CLOSE\" onclick=\"project_form_close()\">X</a> &nbsp; </td></tr></table></div>");
            Output.WriteLine("  <br />");
            Output.WriteLine("  <table class=\"sbkAdm_PopupTable\">");

            // Add line for code
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <td style=\"width:120px;\"><label for=\"form_project_code\">Metadata Code:</label></td>");
            Output.WriteLine("      <td><span class=\"form_linkline admin_existing_code_line\" id=\"form_project_code\"></span></td>");
            Output.WriteLine("    </tr>");

            // Add line for name
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <td><label for=\"form_project_name\">Metadata Name:</label></td>");
            Output.WriteLine("      <td><input class=\"sbkPav_large_input sbkAdmin_Focusable\" name=\"form_project_name\" id=\"form_project_name\" type=\"text\" value=\"\" /></td>");
            Output.WriteLine("    </tr>");

            // Add the buttons and close the table
            Output.WriteLine("    <tr style=\"height:35px; text-align: center; vertical-align: bottom;\">");
            Output.WriteLine("      <td colspan=\"2\"> &nbsp; &nbsp; ");
            Output.WriteLine("        <button title=\"Do not apply changes\" class=\"sbkAdm_RoundButton\" onclick=\"return project_form_close();\"><img src=\"" + currentMode.Base_URL + "default/images/button_previous_arrow.png\" class=\"sbkAdm_RoundButton_LeftImg\" alt=\"\" /> CANCEL</button> &nbsp; &nbsp; ");
            Output.WriteLine("        <button title=\"Save changes to this default metadata\" class=\"sbkAdm_RoundButton\" type=\"submit\">SAVE <img src=\"" + currentMode.Base_URL + "default/images/button_next_arrow.png\" class=\"sbkAdm_RoundButton_RightImg\" alt=\"\" /></button>");
            Output.WriteLine("      </td>");
            Output.WriteLine("    </tr>");
            Output.WriteLine("  </table>");
            Output.WriteLine("</div>");
            Output.WriteLine();

            Tracer.Add_Trace("Default_Metadata_AdminViewer.Write_ItemNavForm_Closing", "Write the rest of the form html");

            // Get the list of all projects
            DataSet projectsSet = SobekCM_Database.Get_All_Template_DefaultMetadatas(Tracer);

            Output.WriteLine("<script src=\"" + currentMode.Base_URL + "default/scripts/sobekcm_admin.js\" type=\"text/javascript\"></script>");
            Output.WriteLine("<div class=\"sbkAdm_HomeText\">");

            if (actionMessage.Length > 0)
            {
                Output.WriteLine("  <br />");
                Output.WriteLine("  <div id=\"sbkAdm_ActionMessage\">" + actionMessage + "</div>");
            }

            Output.WriteLine("  <p>For clarification of any terms on this form, <a href=\"" + SobekCM_Library_Settings.Help_URL(currentMode.Base_URL) + "adminhelp/projects\" target=\"PROJECTS_INTERFACE_HELP\" >click here to view the help page</a>.</p>");

            Output.WriteLine("  <h2>New Default Metadata</h2>");
            Output.WriteLine("  <div class=\"sbkPav_NewDiv\">");
            Output.WriteLine("    <table class=\"sbkAdm_PopupTable\">");

            // Add line for code and base code
            Output.WriteLine("      <tr>");
            Output.WriteLine("        <td style=\"width:120px;\"><label for=\"admin_project_code\">Metadata Code:</label></td>");
            Output.WriteLine("        <td><input class=\"sbkPav_small_input sbkAdmin_Focusable\" name=\"admin_project_code\" id=\"admin_project_code\" type=\"text\" value=\"\" /></td>");
            Output.WriteLine("        <td style=\"width:285px;\">");
            Output.WriteLine("          <label for=\"admin_project_base\">Base Metadata Code:</label> &nbsp; ");
            Output.WriteLine("          <select class=\"sbkPav_select\" name=\"admin_project_base\" id=\"admin_project_base\">");
            Output.WriteLine("            <option value=\"(none)\" selected=\"selected\">(none)</option>");
            foreach (DataRow thisRow in projectsSet.Tables[0].Rows)
            {
                Output.Write("            <option value=\"" + thisRow["MetadataCode"] + "\" >" + thisRow["MetadataCode"] + "</option>");
            }
            Output.WriteLine("          </select>");
            Output.WriteLine("        </td>");
            Output.WriteLine("      </tr>");

            // Add line for name
            Output.WriteLine("      <tr>");
            Output.WriteLine("        <td><label for=\"admin_project_name\">Metadata Name:</label></td>");
            Output.WriteLine("        <td colspan=\"2\"><input class=\"sbkPav_large_input sbkAdmin_Focusable\" name=\"admin_project_name\" id=\"admin_project_name\" type=\"text\" value=\"\" /></td>");
            Output.WriteLine("      <tr>");

            // Add the SAVE button
            Output.WriteLine("      <tr style=\"height:30px; text-align: center;\"><td colspan=\"3\"><button title=\"Save new default metadata\" class=\"sbkAdm_RoundButton\" onclick=\"return save_new_project();\">SAVE <img src=\"" + currentMode.Base_URL + "default/images/button_next_arrow.png\" class=\"sbkAdm_RoundButton_RightImg\" alt=\"\" /></button></td></tr>");
            Output.WriteLine("    </table>");
            Output.WriteLine("  </div>");
            Output.WriteLine("  <br />");
            Output.WriteLine();

            // Add all the existing proejcts
            Output.WriteLine("  <h2>Existing Default Metadata</h2>");
            Output.WriteLine("  <table class=\"sbkPav_Table sbkAdm_Table\">");
            Output.WriteLine("    <tr>");
            Output.WriteLine("      <th class=\"sbkPav_TableHeader1\">ACTIONS</th>");
            Output.WriteLine("      <th class=\"sbkPav_TableHeader2\">CODE</th>");
            Output.WriteLine("      <th class=\"sbkPav_TableHeader3\">NAME</th>");
            Output.WriteLine("    </tr>");
            Output.WriteLine("    <tr><td class=\"sbkAdm_TableRule\" colspan=\"3\"></td></tr>");

            currentMode.My_Sobek_SubMode = "XXXXXXX";
            string redirect = currentMode.Redirect_URL();

            // Write the data for each interface
            foreach (DataRow thisRow in projectsSet.Tables[0].Rows)
            {
                // Pull all these values
                string code = thisRow["MetadataCode"].ToString();
                string name = thisRow["MetadataName"].ToString();

                // Build the action links
                Output.WriteLine("    <tr>");
                Output.Write("      <td class=\"sbkAdm_ActionLink\" >( ");
                Output.Write("<a title=\"Click to edit this default metadata\" href=\"" + redirect.Replace("XXXXXXX", "1" + code) + "\" >edit</a> | ");
                Output.Write("<a title=\"Click to change the name of this default metadata\" href=\"" + currentMode.Base_URL + "l/technical/javascriptrequired\" onclick=\"return project_form_popup('" + code + "','" + name + "');\">rename</a> ");
                if (String.Compare(code, "none", StringComparison.OrdinalIgnoreCase) != 0)
                {
                    if (user.Is_System_Admin)
                    {
                        Output.WriteLine("| <a title=\"Click to delete this default metadata\" href=\"" + currentMode.Base_URL + "l/technical/javascriptrequired\"  onclick=\"return delete_project('" + code + "');\">delete</a> )</td>");
                    }
                    else
                    {
                        Output.WriteLine("| <a title=\"Only SYSTEM administrators can delete default metadata\" href=\"" + currentMode.Base_URL + "l/technical/javascriptrequired\"  onclick=\"alert('Only SYSTEM administrators can delete default metadata'); return false;\">delete</a> )</td>");
                    }
                }
                else
                {
                    Output.WriteLine(")</td>");
                }


                // Add the rest of the row with data
                Output.WriteLine("      <td>" + code + "</td>");
                Output.WriteLine("      <td>" + name + "</td>");
                Output.WriteLine("    </tr>");
                Output.WriteLine("    <tr><td class=\"sbkAdm_TableRule\" colspan=\"3\"></td></tr>");
            }

            Output.WriteLine("  </table>");
            Output.WriteLine("  <br />");
            Output.WriteLine("</div>");
            Output.WriteLine();
        }