/// <summary>Initializes a new instance of <see cref="SlkCulture"/>.</summary>
        /// <param name="web">The web to localize.</param>
        public SlkCulture(SPWeb web)
        {
            Resources = new AppResourcesLocal();
            Culture   = System.Threading.Thread.CurrentThread.CurrentUICulture;
            if (web == null && HttpContext.Current != null)
            {
                web = SPControl.GetContextWeb(HttpContext.Current);
            }

            if (web != null)
            {
#if SP2007
                Culture = web.Locale;
#else
                if (web.IsMultilingual)
                {
                    // Just use the current UI culture as set above
                }
                else
                {
                    // Not a multi-lingual site so return the web's locale
                    Culture = web.Locale;
                }
#endif
            }

            Resources.Culture = Culture;
        }
示例#2
0
        void ChangeToInternationalNames()
        {
            //This is done separately so the internal names are consistent.
            // Change name to internationalized name
#if SP2007
            CultureInfo uiCulture = CultureInfo.CurrentUICulture;
#else
            foreach (CultureInfo uiCulture in web.SupportedUICultures)
#endif
            {
                AppResourcesLocal resources = new AppResourcesLocal();
                resources.Culture = uiCulture;

#if SP2007
                dropBoxList.Title = resources.DropBoxTitle;
#else
                dropBoxList.TitleResource.SetValueForUICulture(uiCulture, resources.DropBoxTitle);
#endif
                ChangeColumnTitle(DropBox.ColumnAssignmentKey, resources.DropBoxColumnAssignmentKey, uiCulture);
                ChangeColumnTitle(DropBox.ColumnAssignmentName, resources.DropBoxColumnAssignmentName, uiCulture);
                ChangeColumnTitle(DropBox.ColumnAssignmentDate, resources.DropBoxColumnAssignmentDate, uiCulture);
                ChangeColumnTitle(DropBox.ColumnAssignmentId, resources.DropBoxColumnAssignmentId, uiCulture);
                ChangeColumnTitle(DropBox.ColumnIsLatest, resources.DropBoxColumnIsLatest, uiCulture);
                ChangeColumnTitle(DropBox.ColumnLearner, resources.DropBoxColumnLearner, uiCulture);
                ChangeColumnTitle(DropBox.ColumnLearnerId, resources.DropBoxColumnLearnerId, uiCulture);
            }

            dropBoxList.Update();
        }
        /// <summary>Loads SLK configuration information from WSS and LearningStore, in a form that's
        /// suitable for copying to Configure.aspx form fields. </summary>
        ///
        /// <param name="spSiteGuid">The GUID of the SPSite to retrieve configuration information
        ///     from.</param>
        ///
        /// <returns>An AdministrationConfiguration.</returns>
        ///
        /// <remarks>
        /// This method is static so it can used outside the context of IIS.  Only SharePoint
        /// administrators can perform this function.
        /// </remarks>
        ///
        /// <exception cref="SafeToDisplayException">
        /// An error occurred that can be displayed to a browser user.
        /// </exception>
        ///
        public static AdministrationConfiguration LoadConfiguration(Guid spSiteGuid)
        {
            AdministrationConfiguration configuration = new AdministrationConfiguration(spSiteGuid);

            // only SharePoint administrators can perform this action
            CheckPermissions();

            // set <mapping> to the mapping between <spSiteGuid> and the LearningStore connection
            // information for that SPSite
            SlkSPSiteMapping mapping = SlkSPSiteMapping.GetMapping(spSiteGuid);

            // set "out" parameters based on <mappingExists> and <mapping>
            if (mapping != null)
            {
                // the mapping exists -- set "out" parameters based on <mapping>
                configuration.DatabaseServer       = mapping.DatabaseServer;
                configuration.DatabaseName         = mapping.DatabaseName;
                configuration.InstructorPermission = mapping.InstructorPermission;
                configuration.LearnerPermission    = mapping.LearnerPermission;

                // The below given condition will be true only during the migration of SLK from
                // 'SLK without Observer role' to 'SLK with Observer role' implementation
                if (mapping.ObserverPermission == null)
                {
                    mapping.ObserverPermission = LoadCulture(spSiteGuid).Resources.DefaultSlkObserverPermissionName;
                }
                configuration.ObserverPermission = mapping.ObserverPermission;
            }
            else
            {
                SlkCulture        siteCulture    = LoadCulture(spSiteGuid);
                AppResourcesLocal adminResources = SlkCulture.GetResources();

                configuration.IsNewConfiguration = true;
                mapping = SlkSPSiteMapping.CreateMapping(spSiteGuid);
                // the mapping doesn't exist -- set "out" parameters to default values
                SPWebService adminWebService = SlkAdministration.GetAdminWebService();
                configuration.DatabaseServer       = adminWebService.DefaultDatabaseInstance.Server.Address;
                configuration.DatabaseName         = adminResources.DefaultSlkDatabaseName;
                mapping.DatabaseServer             = configuration.DatabaseServer;
                mapping.DatabaseName               = configuration.DatabaseName;
                configuration.InstructorPermission = siteCulture.Resources.DefaultSlkInstructorPermissionName;
                configuration.LearnerPermission    = siteCulture.Resources.DefaultSlkLearnerPermissionName;
                configuration.ObserverPermission   = siteCulture.Resources.DefaultSlkObserverPermissionName;
            }

            // set "out" parameters that need to be computed
            bool createDatabaseResult = false;

            SlkUtilities.ImpersonateAppPool(delegate()
            {
                createDatabaseResult = !DatabaseExists(mapping.DatabaseServerConnectionString, mapping.DatabaseName);
            });
            configuration.CreateDatabase = createDatabaseResult;

            return(configuration);
        }
示例#4
0
        SPField AddField(string name, SPFieldType type, bool addToDefaultView, bool required)
        {
            try
            {
                dropBoxList.Fields.Add(name, type, required);
            }
            catch (SPException e)
            {
                AppResourcesLocal resources = new AppResourcesLocal();
                string            message   = string.Format(CultureInfo.CurrentUICulture, resources.DropBoxFailCreateField, name, e.Message);
                throw new SPException(message, e);
            }

            SPField field = dropBoxList.Fields[name];

            if (addToDefaultView)
            {
                dropBoxList.DefaultView.ViewFields.Add(field);
            }

            return(field);
        }
 /// <summary>Initializes a new instance of <see cref="SlkCulture"/>.</summary>
 public SlkCulture(CultureInfo culture)
 {
     Culture           = culture;
     Resources         = new AppResourcesLocal();
     Resources.Culture = Culture;
 }