예제 #1
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Updates a User's Profile
        /// </summary>
        /// <param name="user">The use to update</param>
        /// <param name="profileProperties">The collection of profile properties</param>
        /// <returns>The updated User</returns>
        /// -----------------------------------------------------------------------------
        public static UserInfo UpdateUserProfile(UserInfo user, ProfilePropertyDefinitionCollection profileProperties)
        {
            int portalId = GetEffectivePortalId(user.PortalID);

            user.PortalID = portalId;

            bool updateUser   = Null.NullBoolean;
            var  photoChanged = Null.NullBoolean;

            //Iterate through the Definitions
            if (profileProperties != null)
            {
                foreach (ProfilePropertyDefinition propertyDefinition in profileProperties)
                {
                    string propertyName  = propertyDefinition.PropertyName;
                    string propertyValue = propertyDefinition.PropertyValue;
                    if (propertyDefinition.IsDirty)
                    {
                        if (propertyName.Equals(UserProfile.USERPROFILE_FirstName, StringComparison.InvariantCultureIgnoreCase) ||
                            propertyName.Equals(UserProfile.USERPROFILE_LastName, StringComparison.InvariantCultureIgnoreCase))
                        {
                            updateUser = true;
                        }
                        else if (propertyName.Equals(UserProfile.USERPROFILE_Photo, StringComparison.InvariantCultureIgnoreCase))
                        {
                            photoChanged = true;
                        }
                        else if (propertyName.Equals(UserProfile.USERPROFILE_Biography, StringComparison.InvariantCultureIgnoreCase))
                        {
                            propertyValue = RemoveUnsafeAttributes(propertyValue);
                        }

                        user.Profile.SetProfileProperty(propertyName, propertyValue);
                    }
                }
                UpdateUserProfile(user);

                //if user's photo changed, then create different size thumbnails of profile pictures.
                if (photoChanged)
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(user.Profile.Photo) && int.Parse(user.Profile.Photo) > 0)
                        {
                            CreateThumbnails(int.Parse(user.Profile.Photo));
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Error(ex);
                    }
                }

                if (updateUser)
                {
                    UserController.UpdateUser(portalId, user);
                }
            }
            return(user);
        }
예제 #2
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Updates a User's Profile
        /// </summary>
        /// <param name="user">The use to update</param>
        /// <param name="profileProperties">The collection of profile properties</param>
        /// <returns>The updated User</returns>
        /// -----------------------------------------------------------------------------
        public static UserInfo UpdateUserProfile(UserInfo user, ProfilePropertyDefinitionCollection profileProperties)
        {
            int portalId = GetEffectivePortalId(user.PortalID);

            user.PortalID = portalId;

            bool updateUser = Null.NullBoolean;

            //Iterate through the Definitions
            if (profileProperties != null)
            {
                foreach (ProfilePropertyDefinition propertyDefinition in profileProperties)
                {
                    string propertyName  = propertyDefinition.PropertyName;
                    string propertyValue = propertyDefinition.PropertyValue;
                    if (propertyDefinition.IsDirty)
                    {
                        user.Profile.SetProfileProperty(propertyName, propertyValue);
                        if (propertyName.ToLower() == "firstname" || propertyName.ToLower() == "lastname")
                        {
                            updateUser = true;
                        }
                    }
                }
                UpdateUserProfile(user);
                if (updateUser)
                {
                    UserController.UpdateUser(portalId, user);
                }
            }
            return(user);
        }
예제 #3
0
 private void UpdateTimeZoneInfo(UserInfo user, ProfilePropertyDefinitionCollection properties)
 {
     ProfilePropertyDefinition newTimeZone = properties["PreferredTimeZone"];
     ProfilePropertyDefinition oldTimeZone = properties["TimeZone"];
     if (newTimeZone != null && oldTimeZone != null)
     {
         //Old timezone is present but new is not...we will set that up.
         if (!string.IsNullOrEmpty(oldTimeZone.PropertyValue) && string.IsNullOrEmpty(newTimeZone.PropertyValue))
         {
             int oldOffset;
             int.TryParse(oldTimeZone.PropertyValue, out oldOffset);
             TimeZoneInfo timeZoneInfo = Localization.ConvertLegacyTimeZoneOffsetToTimeZoneInfo(oldOffset);
             newTimeZone.PropertyValue = timeZoneInfo.Id;
             UpdateUserProfile(user);
         }
         //It's also possible that the new value is set but not the old value. We need to make them backwards compatible
         else if (!string.IsNullOrEmpty(newTimeZone.PropertyValue) && string.IsNullOrEmpty(oldTimeZone.PropertyValue))
         {
             TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(newTimeZone.PropertyValue);
             if (timeZoneInfo != null)
             {
                 oldTimeZone.PropertyValue = timeZoneInfo.BaseUtcOffset.TotalMinutes.ToString(CultureInfo.InvariantCulture);
             }
         }
     }
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Add an existing ProfilePropertyDefinitionCollection
 /// </summary>
 /// <param name="collection">A ProfilePropertyDefinitionCollection</param>
 /// -----------------------------------------------------------------------------
 public void AddRange(ProfilePropertyDefinitionCollection collection)
 {
     foreach (ProfilePropertyDefinition objProfilePropertyDefinition in collection)
     {
         Add(objProfilePropertyDefinition);
     }
 }
예제 #5
0
 /// <Summary>Add an existing ProfilePropertyDefinitionCollection</Summary>
 /// <Param name="collection">A ProfilePropertyDefinitionCollection</Param>
 public void AddRange(ProfilePropertyDefinitionCollection collection)
 {
     foreach (ProfilePropertyDefinition propertyDefinition in collection)
     {
         this.Add(propertyDefinition);
     }
 }
예제 #6
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Updates a User's Profile
        /// </summary>
        /// <param name="user">The use to update</param>
        /// <param name="profileProperties">The collection of profile properties</param>
        /// <returns>The updated User</returns>
        /// -----------------------------------------------------------------------------
        public static UserInfo UpdateUserProfile(UserInfo user, ProfilePropertyDefinitionCollection profileProperties)
        {
            int portalId = GetEffectivePortalId(user.PortalID);

            user.PortalID = portalId;

            bool updateUser   = Null.NullBoolean;
            var  photoChanged = Null.NullBoolean;

            //Iterate through the Definitions
            if (profileProperties != null)
            {
                foreach (ProfilePropertyDefinition propertyDefinition in profileProperties)
                {
                    string propertyName  = propertyDefinition.PropertyName;
                    string propertyValue = propertyDefinition.PropertyValue;
                    if (propertyDefinition.IsDirty)
                    {
                        user.Profile.SetProfileProperty(propertyName, propertyValue);
                        if (propertyName.ToLower() == "firstname" || propertyName.ToLower() == "lastname")
                        {
                            updateUser = true;
                        }
                        else if (propertyName.ToLowerInvariant() == "photo")
                        {
                            photoChanged = true;
                        }
                    }
                }
                UpdateUserProfile(user);

                //if user's photo changed, then create different size thumbnails of profile pictures.
                if (photoChanged)
                {
                    try
                    {
                        if (!string.IsNullOrEmpty(user.Profile.Photo) && int.Parse(user.Profile.Photo) > 0)
                        {
                            CreateThumbnails(user.Profile.PhotoURL);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Error(ex);
                    }
                }

                if (updateUser)
                {
                    UserController.UpdateUser(portalId, user);
                }
            }
            return(user);
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets a sub-collection of items in the collection by category.
        /// </summary>
        /// <param name="category">The category to get</param>
        /// <returns>A ProfilePropertyDefinitionCollection object</returns>
        /// -----------------------------------------------------------------------------
        public ProfilePropertyDefinitionCollection GetByCategory(string category)
        {
            var collection = new ProfilePropertyDefinitionCollection();

            foreach (ProfilePropertyDefinition profileProperty in InnerList)
            {
                if (profileProperty.PropertyCategory == category)
                {
                    collection.Add(profileProperty);
                }
            }
            return(collection);
        }
예제 #8
0
        /// <Summary>
        /// Gets a sub-collection of items in the collection by category.
        /// </Summary>
        /// <Param name="category">The category to get</Param>
        /// <Returns>A ProfilePropertyDefinitionCollection object</Returns>
        public ProfilePropertyDefinitionCollection GetByCategory(string category)
        {
            ProfilePropertyDefinitionCollection collection = new ProfilePropertyDefinitionCollection();

            foreach (ProfilePropertyDefinition definition in this.InnerList)
            {
                if (Operators.CompareString(definition.PropertyCategory, category, false) == 0)
                {
                    collection.Add(definition);
                }
            }
            return(collection);
        }
예제 #9
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets a collection of Property Defintions from the Data Store by portal
        /// </summary>
        /// <param name="portalId">The id of the Portal</param>
        /// <param name="clone">Whether to use a clone object.</param>
        /// <param name="includeDeleted">Whether to include deleted profile properties.</param>
        /// <returns>A ProfilePropertyDefinitionCollection object</returns>
        /// -----------------------------------------------------------------------------
        public static ProfilePropertyDefinitionCollection GetPropertyDefinitionsByPortal(int portalId, bool clone, bool includeDeleted)
        {
            portalId = GetEffectivePortalId(portalId);

            var definitions = new ProfilePropertyDefinitionCollection();

            foreach (ProfilePropertyDefinition definition in GetPropertyDefinitions(portalId))
            {
                if (!definition.Deleted || includeDeleted)
                {
                    definitions.Add(clone ? definition.Clone() : definition);
                }
            }
            return(definitions);
        }
예제 #10
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets a collection of Property Defintions from the Data Store by category
        /// </summary>
        /// <param name="portalId">The id of the Portal</param>
        /// <param name="category">The category of the Property Defintions to retrieve</param>
        /// <returns>A ProfilePropertyDefinitionCollection object</returns>
        /// -----------------------------------------------------------------------------
        public static ProfilePropertyDefinitionCollection GetPropertyDefinitionsByCategory(int portalId, string category)
        {
            portalId = GetEffectivePortalId(portalId);

            var definitions = new ProfilePropertyDefinitionCollection();

            foreach (ProfilePropertyDefinition definition in GetPropertyDefinitions(portalId))
            {
                if (definition.PropertyCategory == category)
                {
                    definitions.Add(definition);
                }
            }
            return(definitions);
        }
예제 #11
0
        /// <summary>
        /// Updates a User's Profile
        /// </summary>
        /// <param name="objUser">The use to update</param>
        /// <param name="profileProperties">The collection of profile properties</param>
        /// <returns>The updated User</returns>
        public static UserInfo UpdateUserProfile(UserInfo objUser, ProfilePropertyDefinitionCollection profileProperties)
        {
            //Iterate through the Definitions
            foreach (ProfilePropertyDefinition propertyDefinition in profileProperties)
            {
                string propertyName  = propertyDefinition.PropertyName;
                string propertyValue = propertyDefinition.PropertyValue;

                if (propertyDefinition.IsDirty)
                {
                    //Update Profile
                    objUser.Profile.SetProfileProperty(propertyName, propertyValue);
                }
            }

            UpdateUserProfile(objUser);

            return(objUser);
        }
예제 #12
0
        /// <summary>
        /// Fills a ProfilePropertyDefinitionCollection from a DataReader
        /// </summary>
        /// <param name="dr">An IDataReader object</param>
        /// <returns>The ProfilePropertyDefinitionCollection</returns>
        private static ProfilePropertyDefinitionCollection FillCollection(IDataReader dr)
        {
            ArrayList arrDefinitions = CBO.FillCollection(dr, typeof(ProfilePropertyDefinition));
            ProfilePropertyDefinitionCollection definitionsCollection = new ProfilePropertyDefinitionCollection();
            foreach (ProfilePropertyDefinition definition in arrDefinitions)
            {
                //Clear the Is Dirty Flag
                definition.ClearIsDirty();

                //Initialise the Visibility
                object setting = UserModuleBase.GetSetting(definition.PortalId, "Profile_DefaultVisibility");
                if (setting != null)
                {
                    definition.Visibility = (UserVisibilityMode)Enum.Parse(typeof(UserVisibilityMode),setting.ToString());
                }

                //Add to collection
                definitionsCollection.Add(definition);
            }
            return definitionsCollection;
        }
예제 #13
0
        /// <summary>
        /// Fills a ProfilePropertyDefinitionCollection from a DataReader
        /// </summary>
        /// <param name="dr">An IDataReader object</param>
        /// <returns>The ProfilePropertyDefinitionCollection</returns>
        private static ProfilePropertyDefinitionCollection FillCollection(IDataReader dr)
        {
            ArrayList arrDefinitions = CBO.FillCollection(dr, typeof(ProfilePropertyDefinition));
            ProfilePropertyDefinitionCollection definitionsCollection = new ProfilePropertyDefinitionCollection();

            foreach (ProfilePropertyDefinition definition in arrDefinitions)
            {
                //Clear the Is Dirty Flag
                definition.ClearIsDirty();

                //Initialise the Visibility
                object setting = UserModuleBase.GetSetting(definition.PortalId, "Profile_DefaultVisibility");
                if (setting != null)
                {
                    definition.Visibility = (UserVisibilityMode)Enum.Parse(typeof(UserVisibilityMode), setting.ToString());
                }

                //Add to collection
                definitionsCollection.Add(definition);
            }
            return(definitionsCollection);
        }
예제 #14
0
        protected override void LoadViewState(object savedState)
        {
            if (savedState != null)
            {
                //Load State from the array of objects that was saved with SaveViewState.
                var myState = (object[])savedState;

                //Load Base Controls ViewState
                if (myState[0] != null)
                {
                    base.LoadViewState(myState[0]);
                }

                //Load ModuleID
                if (myState[1] != null)
                {
                    _profileProperties = (ProfilePropertyDefinitionCollection)myState[1];
                }
            }
        }
예제 #15
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// DataBind binds the data to the controls
        /// </summary>
        /// <history>
        /// 	[cnurse]	03/01/2006  Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override void DataBind()
        {
		
            //Before we bind the Profile to the editor we need to "update" the visible data
            var properties = new ProfilePropertyDefinitionCollection();

            foreach (ProfilePropertyDefinition profProperty in UserProfile.ProfileProperties)
            {
                if (IsAdmin && !IsProfile)
                {
                    profProperty.Visible = true;
                }

                if (!profProperty.Deleted)
                {
                    properties.Add(profProperty);
                }
            }

            ProfileProperties.User = User;
            ProfileProperties.ShowVisibility = ShowVisibility;
            ProfileProperties.DataSource = properties;
            ProfileProperties.DataBind();
        }
예제 #16
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Updates a User's Profile
 /// </summary>
 /// <param name="user">The use to update</param>
 /// <param name="profileProperties">The collection of profile properties</param>
 /// <returns>The updated User</returns>
 /// -----------------------------------------------------------------------------
 public static UserInfo UpdateUserProfile(UserInfo user, ProfilePropertyDefinitionCollection profileProperties)
 {
     int portalId = GetEffectivePortalId(user.PortalID);
     user.PortalID = portalId;
     
     bool updateUser = Null.NullBoolean;
     //Iterate through the Definitions
     if (profileProperties != null)
     {
         foreach (ProfilePropertyDefinition propertyDefinition in profileProperties)
         {
             string propertyName = propertyDefinition.PropertyName;
             string propertyValue = propertyDefinition.PropertyValue;
             if (propertyDefinition.IsDirty)
             {
                 user.Profile.SetProfileProperty(propertyName, propertyValue);
                 if (propertyName.ToLower() == "firstname" || propertyName.ToLower() == "lastname")
                 {
                     updateUser = true;
                 }
             }
         }
         UpdateUserProfile(user);
         if (updateUser)
         {
             UserController.UpdateUser(portalId, user);
         }
     }
     return user;
 }
예제 #17
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// DataBind binds the data to the controls
        /// </summary>
        /// <history>
        /// 	[cnurse]	03/01/2006  Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override void DataBind()
        {
		
            //Before we bind the Profile to the editor we need to "update" the visible data
            var properties = new ProfilePropertyDefinitionCollection();
			var imageType = new ListController().GetListEntryInfo("DataType", "Image");
            foreach (ProfilePropertyDefinition profProperty in UserProfile.ProfileProperties)
            {
                if (IsAdmin && !IsProfile)
                {
                    profProperty.Visible = true;
                }

                if (!profProperty.Deleted && (Request.IsAuthenticated || profProperty.DataType != imageType.EntryID))
                {
                    properties.Add(profProperty);
                }
            }

            ProfileProperties.User = User;
            ProfileProperties.ShowVisibility = ShowVisibility;
            ProfileProperties.DataSource = properties;
            ProfileProperties.DataBind();
        }
 /// <Summary>
 /// Gets a sub-collection of items in the collection by category.
 /// </Summary>
 /// <Param name="category">The category to get</Param>
 /// <Returns>A ProfilePropertyDefinitionCollection object</Returns>
 public ProfilePropertyDefinitionCollection GetByCategory( string category )
 {
     ProfilePropertyDefinitionCollection collection = new ProfilePropertyDefinitionCollection();
     foreach( ProfilePropertyDefinition definition in this.InnerList )
     {
         if( Operators.CompareString( definition.PropertyCategory, category, false ) == 0 )
         {
             collection.Add( definition );
         }
     }
     return collection;
 }
예제 #19
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Initialises the Profile with an empty collection of profile properties
 /// </summary>
 /// <remarks></remarks>
 /// <param name="portalId">The name of the property to retrieve.</param>
 /// <param name="useDefaults">A flag that indicates whether the profile default values should be
 /// copied to the Profile.</param>
 /// <history>
 /// 	[cnurse]	08/04/2006	Created
 /// </history>
 /// -----------------------------------------------------------------------------
 public void InitialiseProfile(int portalId, bool useDefaults)
 {
     _profileProperties = ProfileController.GetPropertyDefinitionsByPortal(portalId, true, false);
     if (useDefaults)
     {
         foreach (ProfilePropertyDefinition ProfileProperty in _profileProperties)
         {
             ProfileProperty.PropertyValue = ProfileProperty.DefaultValue;
         }
     }
 }
 /// <summary>
 /// Refresh the Property Collection to the Grid
 /// </summary>
 /// <history>
 ///     [cnurse]	02/23/2006	created
 /// </history>
 private void RefreshGrid()
 {
     ProfileController.ClearProfileDefinitionCache( UsersPortalId );
     m_objProperties = null;
     BindGrid();
 }
예제 #21
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Gets a collection of Property Defintions from the Data Store by category
 /// </summary>
 /// <param name="portalId">The id of the Portal</param>
 /// <param name="category">The category of the Property Defintions to retrieve</param>
 /// <returns>A ProfilePropertyDefinitionCollection object</returns>
 /// -----------------------------------------------------------------------------
 public static ProfilePropertyDefinitionCollection GetPropertyDefinitionsByCategory(int portalId, string category)
 {
     portalId = GetEffectivePortalId(portalId); 
     
     var definitions = new ProfilePropertyDefinitionCollection();
     foreach (ProfilePropertyDefinition definition in GetPropertyDefinitions(portalId))
     {
         if (definition.PropertyCategory == category)
         {
             definitions.Add(definition);
         }
     }
     return definitions;
 }
예제 #22
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets a collection of Property Defintions from the Data Store by portal
        /// </summary>
        /// <param name="portalId">The id of the Portal</param>
        /// <param name="clone">Whether to use a clone object.</param>
        /// <param name="includeDeleted">Whether to include deleted profile properties.</param>
        /// <returns>A ProfilePropertyDefinitionCollection object</returns>
        /// -----------------------------------------------------------------------------
        public static ProfilePropertyDefinitionCollection GetPropertyDefinitionsByPortal(int portalId, bool clone, bool includeDeleted)
        {
            portalId = GetEffectivePortalId(portalId);

            var definitions = new ProfilePropertyDefinitionCollection();
            foreach (ProfilePropertyDefinition definition in GetPropertyDefinitions(portalId))
            {
                if (!definition.Deleted || includeDeleted)
                {
                    definitions.Add(clone ? definition.Clone() : definition);
                }
            }
            return definitions;
        }
예제 #23
0
        /// <summary>
        /// Updates a User's Profile
        /// </summary>
        /// <param name="objUser">The use to update</param>
        /// <param name="profileProperties">The collection of profile properties</param>
        /// <returns>The updated User</returns>
        public static UserInfo UpdateUserProfile(UserInfo objUser, ProfilePropertyDefinitionCollection profileProperties)
        {
            //Iterate through the Definitions
            foreach (ProfilePropertyDefinition propertyDefinition in profileProperties)
            {
                string propertyName = propertyDefinition.PropertyName;
                string propertyValue = propertyDefinition.PropertyValue;

                if (propertyDefinition.IsDirty)
                {
                    //Update Profile
                    objUser.Profile.SetProfileProperty(propertyName, propertyValue);
                }
            }

            UpdateUserProfile(objUser);

            return objUser;
        }
 /// <Summary>Add an existing ProfilePropertyDefinitionCollection</Summary>
 /// <Param name="collection">A ProfilePropertyDefinitionCollection</Param>
 public void AddRange( ProfilePropertyDefinitionCollection collection )
 {
     foreach( ProfilePropertyDefinition propertyDefinition in collection )
     {
         this.Add( propertyDefinition );
     }
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Constructs a new Collection from a ProfilePropertyDefinitionCollection
 /// </summary>
 /// <param name="collection">A ProfilePropertyDefinitionCollection</param>
 /// <history>
 ///     [cnurse]	01/31/2006	created
 /// </history>
 /// -----------------------------------------------------------------------------
 public ProfilePropertyDefinitionCollection(ProfilePropertyDefinitionCollection collection)
 {
     AddRange(collection);
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Gets a sub-collection of items in the collection by category.
 /// </summary>
 /// <param name="category">The category to get</param>
 /// <returns>A ProfilePropertyDefinitionCollection object</returns>
 /// <history>
 ///     [cnurse]	01/31/2006	created
 /// </history>
 /// -----------------------------------------------------------------------------
 public ProfilePropertyDefinitionCollection GetByCategory(string category)
 {
     var collection = new ProfilePropertyDefinitionCollection();
     foreach (ProfilePropertyDefinition profileProperty in InnerList)
     {
         if (profileProperty.PropertyCategory == category)
         {
             collection.Add(profileProperty);
         }
     }
     return collection;
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Add an existing ProfilePropertyDefinitionCollection
 /// </summary>
 /// <param name="collection">A ProfilePropertyDefinitionCollection</param>
 /// <history>
 ///     [cnurse]	01/31/2006	created
 /// </history>
 /// -----------------------------------------------------------------------------
 public void AddRange(ProfilePropertyDefinitionCollection collection)
 {
     foreach (ProfilePropertyDefinition objProfilePropertyDefinition in collection)
     {
         Add(objProfilePropertyDefinition);
     }
 }
예제 #28
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Updates a User's Profile
        /// </summary>
        /// <param name="user">The use to update</param>
        /// <param name="profileProperties">The collection of profile properties</param>
        /// <returns>The updated User</returns>
        /// -----------------------------------------------------------------------------
        public static UserInfo UpdateUserProfile(UserInfo user, ProfilePropertyDefinitionCollection profileProperties)
        {
            int portalId = GetEffectivePortalId(user.PortalID);
            user.PortalID = portalId;
            
            bool updateUser = Null.NullBoolean;
	        var photoChanged = Null.NullBoolean;
            //Iterate through the Definitions
            if (profileProperties != null)
            {
                foreach (ProfilePropertyDefinition propertyDefinition in profileProperties)
                {
                    string propertyName = propertyDefinition.PropertyName;
                    string propertyValue = propertyDefinition.PropertyValue;
                    if (propertyDefinition.IsDirty)
                    {
                        user.Profile.SetProfileProperty(propertyName, propertyValue);
                        if (propertyName.ToLower() == "firstname" || propertyName.ToLower() == "lastname")
                        {
                            updateUser = true;
                        }
						else if (propertyName.ToLowerInvariant() == "photo")
						{
							photoChanged = true;
						}
                    }
                }
                UpdateUserProfile(user);

				//if user's photo changed, then create different size thumbnails of profile pictures.
				if (photoChanged)
				{
					try
					{
						if (!string.IsNullOrEmpty(user.Profile.Photo) && int.Parse(user.Profile.Photo) > 0)
						{
							CreateThumbnails(user.Profile.PhotoURL);
						}
					}
					catch (Exception ex)
					{
						Logger.Error(ex);
					}

				}

                if (updateUser)
                {
                    UserController.UpdateUser(portalId, user);
                }
            }
            return user;
        }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Constructs a new Collection from a ProfilePropertyDefinitionCollection
 /// </summary>
 /// <param name="collection">A ProfilePropertyDefinitionCollection</param>
 /// -----------------------------------------------------------------------------
 public ProfilePropertyDefinitionCollection(ProfilePropertyDefinitionCollection collection)
 {
     AddRange(collection);
 }
예제 #30
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Refresh the Property Collection to the Grid
 /// </summary>
 /// <history>
 ///     [cnurse]	02/23/2006	created
 /// </history>
 /// -----------------------------------------------------------------------------
 private void RefreshGrid()
 {
     _profileProperties = null;
     BindGrid();
 }
 /// <summary>
 /// Gets the properties
 /// </summary>
 /// <history>
 ///     [cnurse]	02/23/2006	created
 /// </history>
 private ProfilePropertyDefinitionCollection GetProperties()
 {
     string strKey = ProfileController.PROPERTIES_CACHEKEY + "." + UsersPortalId;
     if( m_objProperties == null )
     {
         m_objProperties = (ProfilePropertyDefinitionCollection)DataCache.GetCache( strKey );
         if( m_objProperties == null )
         {
             m_objProperties = ProfileController.GetPropertyDefinitionsByPortal( UsersPortalId );
             DataCache.SetCache( strKey, m_objProperties );
         }
     }
     return m_objProperties;
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// DataBind binds the data to the controls
        /// </summary>
        /// <history>
        /// 	[cnurse]	03/01/2006  Created
        /// </history>
        /// -----------------------------------------------------------------------------
        public override void DataBind()
        {
            if (IsAdmin)
            {
                lblTitle.Text = string.Format(Localization.GetString("ProfileTitle.Text", LocalResourceFile), User.Username, User.UserID);
            }
            else if (IsRegister)
            {
                lblTitle.Text = Localization.GetString("RequireProfile.Text", LocalResourceFile);
            }
            else
            {
                divTitle.Visible = false;
            }

            //Before we bind the Profile to the editor we need to "update" the visible data
            ProfilePropertyDefinitionCollection properties = new ProfilePropertyDefinitionCollection();

            foreach (ProfilePropertyDefinition profProperty in UserProfile.ProfileProperties)
            {
                if (IsAdmin && !IsProfile)
                {
                    profProperty.Visible = true;
                }

                if (!profProperty.Deleted)
                    properties.Add(profProperty);
            }
            ProfileProperties.ShowVisibility = ShowVisibility;
            ProfileProperties.DataSource = properties;
            ProfileProperties.DataBind();
        }