예제 #1
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets a Property Defintion from the Data Store by name.
        /// </summary>
        /// <param name="portalId">The id of the Portal.</param>
        /// <param name="name">The name of the ProfilePropertyDefinition object to retrieve.</param>
        /// <returns>The ProfilePropertyDefinition object.</returns>
        /// -----------------------------------------------------------------------------
        public static ProfilePropertyDefinition GetPropertyDefinitionByName(int portalId, string name)
        {
            portalId = GetEffectivePortalId(portalId);

            bool bFound = Null.NullBoolean;
            ProfilePropertyDefinition definition = null;

            foreach (ProfilePropertyDefinition def in GetPropertyDefinitions(portalId))
            {
                if (def.PropertyName == name)
                {
                    definition = def;
                    bFound     = true;
                    break;
                }
            }

            if (!bFound)
            {
                // Try Database
                definition = FillPropertyDefinitionInfo(_dataProvider.GetPropertyDefinitionByName(portalId, name));
            }

            return(definition);
        }
예제 #2
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Updates a Property Defintion in the Data Store.
        /// </summary>
        /// <param name="definition">The ProfilePropertyDefinition object to update.</param>
        /// -----------------------------------------------------------------------------
        public static void UpdatePropertyDefinition(ProfilePropertyDefinition definition)
        {
            if (definition.Required)
            {
                definition.Visible = true;
            }

            _dataProvider.UpdatePropertyDefinition(
                definition.PropertyDefinitionId,
                definition.DataType,
                definition.DefaultValue,
                definition.PropertyCategory,
                definition.PropertyName,
                definition.ReadOnly,
                definition.Required,
                definition.ValidationExpression,
                definition.ViewOrder,
                definition.Visible,
                definition.Length,
                (int)definition.DefaultVisibility,
                UserController.Instance.GetCurrentUserInfo().UserID);
            EventLogController.Instance.AddLog(definition, PortalController.Instance.GetCurrentPortalSettings(), UserController.Instance.GetCurrentUserInfo().UserID, string.Empty, EventLogController.EventLogType.PROFILEPROPERTY_UPDATED);
            ClearProfileDefinitionCache(definition.PortalId);
            ClearAllUsersInfoProfileCacheByPortal(definition.PortalId);
        }
예제 #3
0
        /// <summary>
        /// Clone a ProfilePropertyDefinition
        /// </summary>
        /// <returns>A ProfilePropertyDefinition</returns>
        public ProfilePropertyDefinition Clone()
        {
            var clone = new ProfilePropertyDefinition(PortalId)
            {
                DataType             = DataType,
                DefaultValue         = DefaultValue,
                Length               = Length,
                ModuleDefId          = ModuleDefId,
                PropertyCategory     = PropertyCategory,
                PropertyDefinitionId = PropertyDefinitionId,
                PropertyName         = PropertyName,
                PropertyValue        = PropertyValue,
                ReadOnly             = ReadOnly,
                Required             = Required,
                ValidationExpression = ValidationExpression,
                ViewOrder            = ViewOrder,
                DefaultVisibility    = DefaultVisibility,
                ProfileVisibility    = ProfileVisibility.Clone(),
                Visible              = Visible,
                Deleted              = Deleted
            };

            clone.ClearIsDirty();
            return(clone);
        }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Deletes a Property Defintion from the Data Store
 /// </summary>
 /// <param name="definition">The ProfilePropertyDefinition object to delete</param>
 /// -----------------------------------------------------------------------------
 public static void DeletePropertyDefinition(ProfilePropertyDefinition definition)
 {
     _dataProvider.DeletePropertyDefinition(definition.PropertyDefinitionId);
     EventLogController.Instance.AddLog(definition, PortalController.Instance.GetCurrentPortalSettings(), UserController.Instance.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.PROFILEPROPERTY_DELETED);
     ClearProfileDefinitionCache(definition.PortalId);
     ClearAllUsersInfoProfileCacheByPortal(definition.PortalId);
 }
예제 #5
0
        private static List <ProfilePropertyDefinition> FillPropertyDefinitionInfoCollection(IDataReader dr)
        {
            var arr = new List <ProfilePropertyDefinition>();

            try
            {
                while (dr.Read())
                {
                    //fill business object
                    ProfilePropertyDefinition definition = FillPropertyDefinitionInfo(dr, false);
                    //add to collection
                    arr.Add(definition);
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
            }
            finally
            {
                //close datareader
                CBO.CloseDataReader(dr, true);
            }
            return(arr);
        }
예제 #6
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Adds a Property Defintion to the Data Store
        /// </summary>
        /// <param name="definition">An ProfilePropertyDefinition object</param>
        /// <returns>The Id of the definition (or if negative the errorcode of the error)</returns>
        /// -----------------------------------------------------------------------------
        public static int AddPropertyDefinition(ProfilePropertyDefinition definition)
        {
            int portalId = GetEffectivePortalId(definition.PortalId);

            if (definition.Required)
            {
                definition.Visible = true;
            }
            int intDefinition = _dataProvider.AddPropertyDefinition(portalId,
                                                                    definition.ModuleDefId,
                                                                    definition.DataType,
                                                                    definition.DefaultValue,
                                                                    definition.PropertyCategory,
                                                                    definition.PropertyName,
                                                                    definition.ReadOnly,
                                                                    definition.Required,
                                                                    definition.ValidationExpression,
                                                                    definition.ViewOrder,
                                                                    definition.Visible,
                                                                    definition.Length,
                                                                    (int)definition.DefaultVisibility,
                                                                    UserController.Instance.GetCurrentUserInfo().UserID);

            EventLogController.Instance.AddLog(definition, PortalController.Instance.GetCurrentPortalSettings(), UserController.Instance.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.PROFILEPROPERTY_CREATED);
            ClearProfileDefinitionCache(definition.PortalId);
            return(intDefinition);
        }
예제 #7
0
        /// <summary>
        /// Adds a single default property definition
        /// </summary>
        /// <param name="PortalId">Id of the Portal</param>
        /// <param name="category">Category of the Property</param>
        /// <param name="name">Name of the Property</param>
        private static void AddDefaultDefinition(int PortalId, string category, string name, string strType, int length, ListEntryInfoCollection types)
        {
            ListEntryInfo typeInfo = types.Item("DataType." + strType);

            if (typeInfo == null)
            {
                typeInfo = types.Item("DataType.Unknown");
            }

            ProfilePropertyDefinition propertyDefinition = new ProfilePropertyDefinition();

            propertyDefinition.DataType         = typeInfo.EntryID;
            propertyDefinition.DefaultValue     = "";
            propertyDefinition.ModuleDefId      = Null.NullInteger;
            propertyDefinition.PortalId         = PortalId;
            propertyDefinition.PropertyCategory = category;
            propertyDefinition.PropertyName     = name;
            propertyDefinition.Required         = false;
            propertyDefinition.Visible          = true;
            propertyDefinition.Length           = length;

            _orderCounter += 2;

            propertyDefinition.ViewOrder = _orderCounter;

            AddPropertyDefinition(propertyDefinition);
        }
예제 #8
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Deletes a Property Defintion from the Data Store
        /// </summary>
        /// <param name="definition">The ProfilePropertyDefinition object to delete</param>
        /// -----------------------------------------------------------------------------
        public static void DeletePropertyDefinition(ProfilePropertyDefinition definition)
        {
            _dataProvider.DeletePropertyDefinition(definition.PropertyDefinitionId);
            var objEventLog = new EventLogController();

            objEventLog.AddLog(definition, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.PROFILEPROPERTY_DELETED);
            ClearProfileDefinitionCache(definition.PortalId);
        }
예제 #9
0
 private static string DisplayDataType(ProfilePropertyDefinition definition)
 {
     string cacheKey = string.Format("DisplayDataType:{0}", definition.DataType);
     string strDataType = Convert.ToString(DataCache.GetCache(cacheKey)) + "";
     if (strDataType == string.Empty)
     {
         var objListController = new ListController();
         strDataType = objListController.GetListEntryInfo(definition.DataType).Value;
         DataCache.SetCache(cacheKey, strDataType);
     }
     return strDataType;
 }
예제 #10
0
        /// <Summary>Gets an item in the collection by name.</Summary>
        /// <Param name="name">The name of the Property to get</Param>
        /// <Returns>A ProfilePropertyDefinition object</Returns>
        public ProfilePropertyDefinition GetByName(string name)
        {
            ProfilePropertyDefinition definition = null;

            foreach (ProfilePropertyDefinition propertyDefinition in this.InnerList)
            {
                if (Operators.CompareString(propertyDefinition.PropertyName, name, false) == 0)
                {
                    definition = propertyDefinition;
                }
            }
            return(definition);
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets an item in the collection by Id.
        /// </summary>
        /// <param name="id">The id of the Property to get</param>
        /// <returns>A ProfilePropertyDefinition object</returns>
        /// -----------------------------------------------------------------------------
        public ProfilePropertyDefinition GetById(int id)
        {
            ProfilePropertyDefinition profileItem = null;

            foreach (ProfilePropertyDefinition profileProperty in InnerList)
            {
                if (profileProperty.PropertyDefinitionId == id)
                {
                    profileItem = profileProperty;
                }
            }
            return(profileItem);
        }
예제 #12
0
        /// <Summary>Gets an item in the collection by Id.</Summary>
        /// <Param name="id">The id of the Property to get</Param>
        /// <Returns>A ProfilePropertyDefinition object</Returns>
        public ProfilePropertyDefinition GetById(int id)
        {
            ProfilePropertyDefinition definition = ((ProfilePropertyDefinition)null);

            foreach (ProfilePropertyDefinition propertyDefinition in this.InnerList)
            {
                if (propertyDefinition.PropertyDefinitionId == id)
                {
                    definition = propertyDefinition;
                }
            }
            return(definition);
        }
예제 #13
0
        private bool CheckAccessLevel(ProfilePropertyDefinition property, UserInfo accessingUser)
        {
            var isAdminUser = IsAdminUser(accessingUser);

            //Use properties visible property but admins and hosts can always see the property
            var isVisible = property.Visible || isAdminUser;

            if (isVisible && !isAdminUser)
            {
                switch (property.ProfileVisibility.VisibilityMode)
                {
                    case UserVisibilityMode.FriendsAndGroups:
                        isVisible = IsUser(accessingUser);
                        if(!isVisible)
                        {
                            //Relationships
                            foreach (Relationship relationship in property.ProfileVisibility.RelationshipVisibilities)
                            {
                                if (user.Social.UserRelationships.Any(userRelationship =>
                                                                          (userRelationship.RelationshipId == relationship.RelationshipId
                                                                              && userRelationship.Status == RelationshipStatus.Accepted
                                                                              && (accessingUser.UserID == userRelationship.RelatedUserId || user.UserID==userRelationship.RelatedUserId))
                                                                      ))
                                {
                                    isVisible = true;
                                    break;
                                }
                            }
                            //Groups/Roles
                            if (property.ProfileVisibility.RoleVisibilities.Any(role => accessingUser.IsInRole(role.RoleName)))
                            {
                                isVisible = true;
                            }
                        }
                        break;
                    case UserVisibilityMode.AllUsers:
                        // property is visible to everyone so do nothing
                        break;
                    case UserVisibilityMode.MembersOnly:
                        // property visible if accessing user is a member
                        isVisible = IsMember(accessingUser);
                        break;
                    case UserVisibilityMode.AdminOnly:
                        //accessing user not admin user so property is hidden (unless it is the user him/herself)
                        isVisible = IsUser(accessingUser);
                        break;
                }               
            }

            return isVisible;
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Gets an item in the collection by name.
        /// </summary>
        /// <param name="name">The name of the Property to get</param>
        /// <returns>A ProfilePropertyDefinition object</returns>
        /// -----------------------------------------------------------------------------
        public ProfilePropertyDefinition GetByName(string name)
        {
            ProfilePropertyDefinition profileItem = null;

            foreach (ProfilePropertyDefinition profileProperty in InnerList)
            {
                if (profileProperty.PropertyName == name)
                {
                    //Found Profile property
                    profileItem = profileProperty;
                }
            }
            return(profileItem);
        }
예제 #15
0
        private static ProfilePropertyDefinition FillPropertyDefinitionInfo(IDataReader dr, bool checkForOpenDataReader)
        {
            ProfilePropertyDefinition definition = null;

            // read datareader
            bool canContinue = true;

            if (checkForOpenDataReader)
            {
                canContinue = false;
                if (dr.Read())
                {
                    canContinue = true;
                }
            }

            if (canContinue)
            {
                int portalid = 0;
                portalid   = Convert.ToInt32(Null.SetNull(dr["PortalId"], portalid));
                definition = new ProfilePropertyDefinition(portalid);
                definition.PropertyDefinitionId = Convert.ToInt32(Null.SetNull(dr["PropertyDefinitionId"], definition.PropertyDefinitionId));
                definition.ModuleDefId          = Convert.ToInt32(Null.SetNull(dr["ModuleDefId"], definition.ModuleDefId));
                definition.DataType             = Convert.ToInt32(Null.SetNull(dr["DataType"], definition.DataType));
                definition.DefaultValue         = Convert.ToString(Null.SetNull(dr["DefaultValue"], definition.DefaultValue));
                definition.PropertyCategory     = Convert.ToString(Null.SetNull(dr["PropertyCategory"], definition.PropertyCategory));
                definition.PropertyName         = Convert.ToString(Null.SetNull(dr["PropertyName"], definition.PropertyName));
                definition.Length = Convert.ToInt32(Null.SetNull(dr["Length"], definition.Length));
                if (dr.GetSchemaTable().Select("ColumnName = 'ReadOnly'").Length > 0)
                {
                    definition.ReadOnly = Convert.ToBoolean(Null.SetNull(dr["ReadOnly"], definition.ReadOnly));
                }

                definition.Required             = Convert.ToBoolean(Null.SetNull(dr["Required"], definition.Required));
                definition.ValidationExpression = Convert.ToString(Null.SetNull(dr["ValidationExpression"], definition.ValidationExpression));
                definition.ViewOrder            = Convert.ToInt32(Null.SetNull(dr["ViewOrder"], definition.ViewOrder));
                definition.Visible           = Convert.ToBoolean(Null.SetNull(dr["Visible"], definition.Visible));
                definition.DefaultVisibility = (UserVisibilityMode)Convert.ToInt32(Null.SetNull(dr["DefaultVisibility"], definition.DefaultVisibility));
                definition.ProfileVisibility = new ProfileVisibility
                {
                    VisibilityMode = definition.DefaultVisibility,
                };
                definition.Deleted = Convert.ToBoolean(Null.SetNull(dr["Deleted"], definition.Deleted));
            }

            return(definition);
        }
예제 #16
0
        private static ProfilePropertyDefinition FillPropertyDefinitionInfo(IDataReader dr)
        {
            ProfilePropertyDefinition definition = null;

            try
            {
                definition = FillPropertyDefinitionInfo(dr, true);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }
            finally
            {
                CBO.CloseDataReader(dr, true);
            }
            return(definition);
        }
예제 #17
0
        internal static void AddDefaultDefinition(int portalId, string category, string name, string type, int length, int viewOrder, UserVisibilityMode defaultVisibility,
                                                  Dictionary <string, ListEntryInfo> types)
        {
            ListEntryInfo typeInfo           = types["DataType:" + type] ?? types["DataType:Unknown"];
            var           propertyDefinition = new ProfilePropertyDefinition(portalId)
            {
                DataType          = typeInfo.EntryID,
                DefaultValue      = "",
                ModuleDefId       = Null.NullInteger,
                PropertyCategory  = category,
                PropertyName      = name,
                Required          = false,
                ViewOrder         = viewOrder,
                Visible           = true,
                Length            = length,
                DefaultVisibility = defaultVisibility
            };

            AddPropertyDefinition(propertyDefinition);
        }
예제 #18
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Adds the default property definitions for a portal
        /// </summary>
        /// <param name="portalId">Id of the Portal</param>
        /// -----------------------------------------------------------------------------
        public static void AddDefaultDefinitions(int portalId)
        {
            portalId = GetEffectivePortalId(portalId);

            _orderCounter = 1;
            var listController = new ListController();
            Dictionary <string, ListEntryInfo> dataTypes = listController.GetListEntryInfoDictionary("DataType");

            AddDefaultDefinition(portalId, "Name", "Prefix", "Text", 50, UserVisibilityMode.AllUsers, dataTypes);
            AddDefaultDefinition(portalId, "Name", "FirstName", "Text", 50, UserVisibilityMode.AllUsers, dataTypes);
            AddDefaultDefinition(portalId, "Name", "MiddleName", "Text", 50, UserVisibilityMode.AllUsers, dataTypes);
            AddDefaultDefinition(portalId, "Name", "LastName", "Text", 50, UserVisibilityMode.AllUsers, dataTypes);
            AddDefaultDefinition(portalId, "Name", "Suffix", "Text", 50, UserVisibilityMode.AllUsers, dataTypes);
            AddDefaultDefinition(portalId, "Address", "Unit", "Text", 50, UserVisibilityMode.AdminOnly, dataTypes);
            AddDefaultDefinition(portalId, "Address", "Street", "Text", 50, UserVisibilityMode.AdminOnly, dataTypes);
            AddDefaultDefinition(portalId, "Address", "City", "Text", 50, UserVisibilityMode.AdminOnly, dataTypes);
            AddDefaultDefinition(portalId, "Address", "Region", "Region", 0, UserVisibilityMode.AdminOnly, dataTypes);
            AddDefaultDefinition(portalId, "Address", "Country", "Country", 0, UserVisibilityMode.AdminOnly, dataTypes);
            AddDefaultDefinition(portalId, "Address", "PostalCode", "Text", 50, UserVisibilityMode.AdminOnly, dataTypes);
            AddDefaultDefinition(portalId, "Contact Info", "Telephone", "Text", 50, UserVisibilityMode.AdminOnly, dataTypes);
            AddDefaultDefinition(portalId, "Contact Info", "Cell", "Text", 50, UserVisibilityMode.AdminOnly, dataTypes);
            AddDefaultDefinition(portalId, "Contact Info", "Fax", "Text", 50, UserVisibilityMode.AdminOnly, dataTypes);
            AddDefaultDefinition(portalId, "Contact Info", "Website", "Text", 50, UserVisibilityMode.AdminOnly, dataTypes);
            AddDefaultDefinition(portalId, "Contact Info", "IM", "Text", 50, UserVisibilityMode.AdminOnly, dataTypes);
            AddDefaultDefinition(portalId, "Preferences", "Biography", "Multi-line Text", 0, UserVisibilityMode.AdminOnly, dataTypes);
            AddDefaultDefinition(portalId, "Preferences", "TimeZone", "TimeZone", 0, UserVisibilityMode.AdminOnly, dataTypes);
            AddDefaultDefinition(portalId, "Preferences", "PreferredTimeZone", "TimeZoneInfo", 0, UserVisibilityMode.AdminOnly, dataTypes);
            AddDefaultDefinition(portalId, "Preferences", "PreferredLocale", "Locale", 0, UserVisibilityMode.AdminOnly, dataTypes);
            AddDefaultDefinition(portalId, "Preferences", "Photo", "Image", 0, UserVisibilityMode.AllUsers, dataTypes);

            //6.0 requires the old TimeZone property to be marked as Deleted
            ProfilePropertyDefinition pdf = GetPropertyDefinitionByName(portalId, "TimeZone");

            if (pdf != null)
            {
                DeletePropertyDefinition(pdf);
            }
        }
    static public void SetUserProfileProperty(int PortalId, int UserId, String PropertyName, String PropertyValue, int DataType = 349)
    {
        var pd = DotNetNuke.Entities.Profile.ProfileController.GetPropertyDefinitionByName(PortalId, PropertyName);

        if (pd == null)
        {
            DotNetNuke.Entities.Profile.ProfilePropertyDefinition insert = new DotNetNuke.Entities.Profile.ProfilePropertyDefinition(PortalId);
            insert.DefaultValue     = "";
            insert.Deleted          = false;
            insert.DataType         = DataType;
            insert.PropertyCategory = "Other";
            insert.PropertyName     = PropertyName;
            insert.Length           = 50;
            insert.Required         = false;
            insert.ViewOrder        = 200;
            insert.Visible          = true;

            DotNetNuke.Entities.Profile.ProfileController.AddPropertyDefinition(insert);
        }

        DotNetNuke.Entities.Users.UserInfo theUser = DotNetNuke.Entities.Users.UserController.GetUserById(PortalId, UserId);
        theUser.Profile.SetProfileProperty(PropertyName, PropertyValue);
        DotNetNuke.Entities.Users.UserController.UpdateUser(PortalId, theUser);
    }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Gets the index of a property Definition
 /// </summary>
 /// <param name="value">A ProfilePropertyDefinition object</param>
 /// <returns>The index of the property Definition in the collection</returns>
 /// -----------------------------------------------------------------------------
 public int IndexOf(ProfilePropertyDefinition value)
 {
     return(List.IndexOf(value));
 }
예제 #21
0
 /// <summary>
 /// Deletes a Property Defintion from the Data Store
 /// </summary>
 /// <param name="definition">The ProfilePropertyDefinition object to delete</param>
 public static void DeletePropertyDefinition(ProfilePropertyDefinition definition)
 {
     DeletePropertyDefinition(definition.PropertyDefinitionId);
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Adds a property Definition to the collectio.
 /// </summary>
 /// <param name="value">A ProfilePropertyDefinition object</param>
 /// <returns>The index of the property Definition in the collection</returns>
 /// -----------------------------------------------------------------------------
 public int Add(ProfilePropertyDefinition value)
 {
     return(List.Add(value));
 }
예제 #23
0
 /// <summary>
 /// Adds a Property Defintion to the Data Store
 /// </summary>
 /// <param name="definition">An ProfilePropertyDefinition object</param>
 /// <returns>The Id of the definition (or if negative the errorcode of the error)</returns>
 public static int AddPropertyDefinition(ProfilePropertyDefinition definition)
 {
     return provider.AddPropertyDefinition(definition.PortalId, definition.ModuleDefId, definition.DataType, definition.DefaultValue, definition.PropertyCategory, definition.PropertyName, definition.Required, definition.ValidationExpression, definition.ViewOrder, definition.Visible, definition.Length);
 }
예제 #24
0
 private void AddProperty(ProfilePropertyDefinition property)
 {
     var controller = new ListController();
     ListEntryInfo imageType = controller.GetListEntryInfo("DataType", "Image");
     if (property.DataType != imageType.EntryID)
     {
         DnnFormEditControlItem formItem = new DnnFormEditControlItem
                                                 {
                                                     ID = property.PropertyName,
                                                     ResourceKey = String.Format("ProfileProperties_{0}", property.PropertyName),
                                                     LocalResourceFile = "~/DesktopModules/Admin/Security/App_LocalResources/Profile.ascx.resx",
                                                     ControlType = EditorInfo.GetEditor(property.DataType),
                                                     DataMember = "Profile",
                                                     DataField = property.PropertyName,
                                                     Visible = property.Visible,
                                                     Required = property.Required
                                                 };
         //To check if the property has a deafult value
         if (!String.IsNullOrEmpty(property.DefaultValue))
         {
             formItem.Value = property.DefaultValue;
         }
         userForm.Items.Add(formItem);
     }
 }
예제 #25
0
        private static void ParseProfileDefinitions(XmlNode nodeProfileDefinitions, int PortalId)
        {
            var listController = new ListController();
            Dictionary<string, ListEntryInfo> colDataTypes = listController.GetListEntryInfoDictionary("DataType");

            int orderCounter = -1;
            ProfilePropertyDefinition objProfileDefinition;
            bool preferredTimeZoneFound = false;
            foreach (XmlNode node in nodeProfileDefinitions.SelectNodes("//profiledefinition"))
            {
                orderCounter += 2;
                ListEntryInfo typeInfo;
                if (!colDataTypes.TryGetValue("DataType:" + XmlUtils.GetNodeValue(node.CreateNavigator(), "datatype"), out typeInfo))
                {
                    typeInfo = colDataTypes["DataType:Unknown"];
                }
                objProfileDefinition = new ProfilePropertyDefinition(PortalId);
                objProfileDefinition.DataType = typeInfo.EntryID;
                objProfileDefinition.DefaultValue = "";
                objProfileDefinition.ModuleDefId = Null.NullInteger;
                objProfileDefinition.PropertyCategory = XmlUtils.GetNodeValue(node.CreateNavigator(), "propertycategory");
                objProfileDefinition.PropertyName = XmlUtils.GetNodeValue(node.CreateNavigator(), "propertyname");
                objProfileDefinition.Required = false;
                objProfileDefinition.Visible = true;
                objProfileDefinition.ViewOrder = orderCounter;
                objProfileDefinition.Length = XmlUtils.GetNodeValueInt(node, "length");

                switch (XmlUtils.GetNodeValueInt(node, "defaultvisibility", 2))
                {
                    case 0:
                        objProfileDefinition.DefaultVisibility = UserVisibilityMode.AllUsers;
                        break;
                    case 1:
                        objProfileDefinition.DefaultVisibility = UserVisibilityMode.MembersOnly;
                        break;
                    case 2:
                        objProfileDefinition.DefaultVisibility = UserVisibilityMode.AdminOnly;
                        break;
                }

                if (objProfileDefinition.PropertyName == "PreferredTimeZone")
                {
                    preferredTimeZoneFound = true;
                }

                ProfileController.AddPropertyDefinition(objProfileDefinition);
            }

            //6.0 requires the old TimeZone property to be marked as Deleted
            ProfilePropertyDefinition pdf = ProfileController.GetPropertyDefinitionByName(PortalId, "TimeZone");
            if (pdf != null)
            {
                ProfileController.DeletePropertyDefinition(pdf);
            }

            // 6.0 introduced a new property called as PreferredTimeZone. If this property is not present in template
            // it should be added. Situation will mostly happen while using an older template file.
            if (!preferredTimeZoneFound)
            {
                orderCounter += 2;

                ListEntryInfo typeInfo = colDataTypes["DataType:TimeZoneInfo"];
                if (typeInfo == null)
                {
                    typeInfo = colDataTypes["DataType:Unknown"];
                }

                objProfileDefinition = new ProfilePropertyDefinition(PortalId);
                objProfileDefinition.DataType = typeInfo.EntryID;
                objProfileDefinition.DefaultValue = "";
                objProfileDefinition.ModuleDefId = Null.NullInteger;
                objProfileDefinition.PropertyCategory = "Preferences";
                objProfileDefinition.PropertyName = "PreferredTimeZone";
                objProfileDefinition.Required = false;
                objProfileDefinition.Visible = true;
                objProfileDefinition.ViewOrder = orderCounter;
                objProfileDefinition.Length = 0;
                objProfileDefinition.DefaultVisibility = UserVisibilityMode.AdminOnly;
                ProfileController.AddPropertyDefinition(objProfileDefinition);
            }
        }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Removes a property definition from the collection
 /// </summary>
 /// <param name="value">The ProfilePropertyDefinition object to remove</param>
 /// <history>
 ///     [cnurse]	01/31/2006	created
 /// </history>
 /// -----------------------------------------------------------------------------
 public void Remove(ProfilePropertyDefinition value)
 {
     List.Remove(value);
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Inserts a property Definition into the collectio.
 /// </summary>
 /// <param name="value">A ProfilePropertyDefinition object</param>
 /// <param name="index">The index to insert the item at</param>
 /// <history>
 ///     [cnurse]	01/31/2006	created
 /// </history>
 /// -----------------------------------------------------------------------------
 public void Insert(int index, ProfilePropertyDefinition value)
 {
     List.Insert(index, value);
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Gets the index of a property Definition
 /// </summary>
 /// <param name="value">A ProfilePropertyDefinition object</param>
 /// <returns>The index of the property Definition in the collection</returns>
 /// <history>
 ///     [cnurse]	01/31/2006	created
 /// </history>
 /// -----------------------------------------------------------------------------
 public int IndexOf(ProfilePropertyDefinition value)
 {
     return List.IndexOf(value);
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Determines whether the collection contains a property definition
 /// </summary>
 /// <param name="value">A ProfilePropertyDefinition object</param>
 /// <returns>A Boolean True/False</returns>
 /// <history>
 ///     [cnurse]	01/31/2006	created
 /// </history>
 /// -----------------------------------------------------------------------------
 public bool Contains(ProfilePropertyDefinition value)
 {
     return List.Contains(value);
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Adds a property Definition to the collectio.
 /// </summary>
 /// <param name="value">A ProfilePropertyDefinition object</param>
 /// <returns>The index of the property Definition in the collection</returns>
 /// <history>
 ///     [cnurse]	01/31/2006	created
 /// </history>
 /// -----------------------------------------------------------------------------
 public int Add(ProfilePropertyDefinition value)
 {
     return List.Add(value);
 }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Removes a property definition from the collection
 /// </summary>
 /// <param name="value">The ProfilePropertyDefinition object to remove</param>
 /// -----------------------------------------------------------------------------
 public void Remove(ProfilePropertyDefinition value)
 {
     List.Remove(value);
 }
예제 #32
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Deletes a Property Defintion from the Data Store
 /// </summary>
 /// <param name="definition">The ProfilePropertyDefinition object to delete</param>
 /// -----------------------------------------------------------------------------
 public static void DeletePropertyDefinition(ProfilePropertyDefinition definition)
 {
     _dataProvider.DeletePropertyDefinition(definition.PropertyDefinitionId);
     var objEventLog = new EventLogController();
     objEventLog.AddLog(definition, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.PROFILEPROPERTY_DELETED);
     ClearProfileDefinitionCache(definition.PortalId);
 }
예제 #33
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Adds a Property Defintion to the Data Store
 /// </summary>
 /// <param name="definition">An ProfilePropertyDefinition object</param>
 /// <returns>The Id of the definition (or if negative the errorcode of the error)</returns>
 /// -----------------------------------------------------------------------------
 public static int AddPropertyDefinition(ProfilePropertyDefinition definition)
 {
     int portalId = GetEffectivePortalId(definition.PortalId);
     if (definition.Required)
     {
         definition.Visible = true;
     }
     int intDefinition = _dataProvider.AddPropertyDefinition(portalId,
                                                        definition.ModuleDefId,
                                                        definition.DataType,
                                                        definition.DefaultValue,
                                                        definition.PropertyCategory,
                                                        definition.PropertyName,
                                                        definition.ReadOnly,
                                                        definition.Required,
                                                        definition.ValidationExpression,
                                                        definition.ViewOrder,
                                                        definition.Visible,
                                                        definition.Length,
                                                        (int) definition.DefaultVisibility,
                                                        UserController.GetCurrentUserInfo().UserID);
     var objEventLog = new EventLogController();
     objEventLog.AddLog(definition, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.PROFILEPROPERTY_CREATED);
     ClearProfileDefinitionCache(definition.PortalId);
     return intDefinition;
 }
예제 #34
0
 internal static void AddDefaultDefinition(int portalId, string category, string name, string type, int length, int viewOrder, UserVisibilityMode defaultVisibility,
                                           Dictionary<string, ListEntryInfo> types)
 {
     ListEntryInfo typeInfo = types["DataType:" + type] ?? types["DataType:Unknown"];
     var propertyDefinition = new ProfilePropertyDefinition(portalId)
                                  {
                                      DataType = typeInfo.EntryID,
                                      DefaultValue = "",
                                      ModuleDefId = Null.NullInteger,
                                      PropertyCategory = category,
                                      PropertyName = name,
                                      Required = false,
                                      ViewOrder = viewOrder,
                                      Visible = true,
                                      Length = length,
                                      DefaultVisibility = defaultVisibility
                                  };
     AddPropertyDefinition(propertyDefinition);
 }
예제 #35
0
 /// <summary>
 /// Deletes a Property Defintion from the Data Store
 /// </summary>
 /// <param name="definition">The ProfilePropertyDefinition object to delete</param>
 public static void DeletePropertyDefinition(ProfilePropertyDefinition definition)
 {
     DeletePropertyDefinition(definition.PropertyDefinitionId);
 }
 public string DisplayDefaultVisibility(ProfilePropertyDefinition definition)
 {
     string retValue = Null.NullString;
     if (!String.IsNullOrEmpty(definition.DefaultVisibility.ToString()))
     {
         retValue = LocalizeString(definition.DefaultVisibility.ToString()) ?? definition.DefaultVisibility.ToString();
     }
     return retValue;
 }
    public static void SetUserProfileProperty(int PortalId, int UserId, String PropertyName, String PropertyValue, int DataType = 349)
    {
        var pd = DotNetNuke.Entities.Profile.ProfileController.GetPropertyDefinitionByName(PortalId, PropertyName);
        if (pd == null)
        {
            DotNetNuke.Entities.Profile.ProfilePropertyDefinition insert = new DotNetNuke.Entities.Profile.ProfilePropertyDefinition(PortalId);
            insert.DefaultValue = "";
            insert.Deleted = false;
            insert.DataType = DataType;
            insert.PropertyCategory = "Other";
            insert.PropertyName = PropertyName;
            insert.Length = 50;
            insert.Required = false;
            insert.ViewOrder = 200;
            insert.Visible = true;

            DotNetNuke.Entities.Profile.ProfileController.AddPropertyDefinition(insert);
        }

        DotNetNuke.Entities.Users.UserInfo theUser = DotNetNuke.Entities.Users.UserController.GetUserById(PortalId, UserId);
        theUser.Profile.SetProfileProperty(PropertyName, PropertyValue);
        DotNetNuke.Entities.Users.UserController.UpdateUser(PortalId, theUser);
    }
        private bool ValidateProperty(ProfilePropertyDefinition definition)
        {
            bool isValid = true;

            var objListController = new ListController();
            string strDataType = objListController.GetListEntryInfo(definition.DataType).Value;

            switch (strDataType)
            {
                case "Text":
                    if (definition.Required && definition.Length == 0)
                    {
                        _Message = "RequiredTextBox";
                        isValid = Null.NullBoolean;
                    }
                    break;
            }
            return isValid;
        }
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// <history>
        /// 	[cnurse]	02/22/2006  Created
        /// </history>
        protected void Page_Load( Object sender, EventArgs e )
        {
            try
            {
                //Declare Property Definition object
                ProfilePropertyDefinition propertyDefinition;

                if( PropertyDefinitionId != Null.NullInteger )
                {
                    //Get Property Definition from Data Store
                    propertyDefinition = ProfileController.GetPropertyDefinition( PropertyDefinitionId );
                }
                else
                {
                    //Create New Property Definition
                    propertyDefinition = new ProfilePropertyDefinition();
                    propertyDefinition.PortalId = PortalId;
                }

                cmdDelete.Visible = true;
                ClientAPI.AddButtonConfirm( cmdDelete, Localization.GetString( "DeleteItem" ) );

                //Bind Property Definition to Data Store
                Properties.LocalResourceFile = this.LocalResourceFile;
                Properties.DataSource = propertyDefinition;
                Properties.DataBind();
            }
            catch( Exception exc ) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException( this, exc );
            }
        }
예제 #40
0
 /// <summary>
 /// Updates a Property Defintion in the Data Store
 /// </summary>
 /// <param name="definition">The ProfilePropertyDefinition object to update</param>
 public static void UpdatePropertyDefinition(ProfilePropertyDefinition definition)
 {
     provider.UpdatePropertyDefinition(definition.PropertyDefinitionId, definition.DataType, definition.DefaultValue, definition.PropertyCategory, definition.PropertyName, definition.Required, definition.ValidationExpression, definition.ViewOrder, definition.Visible, definition.Length);
 }
예제 #41
0
        /// <summary>
        /// Processes all Profile Definitions from the template
        /// </summary>
        /// <param name="nodeProfileDefinitions">Template file node for the Profile Definitions</param>
        /// <param name="PortalId">PortalId of the new portal</param>
        private void ParseProfileDefinitions( XmlNode nodeProfileDefinitions, int PortalId )
        {
            ListController objListController = new ListController();
            ListEntryInfoCollection colDataTypes = objListController.GetListEntryInfoCollection( "DataType" );

            int OrderCounter = -1;

            ProfilePropertyDefinition objProfileDefinition = null;

            foreach( XmlNode node in nodeProfileDefinitions.SelectNodes( "//profiledefinition" ) )
            {
                OrderCounter += 2;

                ListEntryInfo typeInfo = colDataTypes.Item( "DataType." + XmlUtils.GetNodeValue( node, "datatype", "" ) );
                if( typeInfo == null )
                {
                    typeInfo = colDataTypes.Item("DataType.Unknown");
                }

                objProfileDefinition = new ProfilePropertyDefinition();
                objProfileDefinition.DataType = typeInfo.EntryID;
                objProfileDefinition.DefaultValue = "";
                objProfileDefinition.ModuleDefId = Null.NullInteger;
                objProfileDefinition.PortalId = PortalId;
                objProfileDefinition.PropertyCategory = XmlUtils.GetNodeValue( node, "propertycategory", "" );
                objProfileDefinition.PropertyName = XmlUtils.GetNodeValue( node, "propertyname", "" );
                objProfileDefinition.Required = false;
                objProfileDefinition.Visible = true;
                objProfileDefinition.ViewOrder = OrderCounter;
                objProfileDefinition.Length = XmlUtils.GetNodeValueInt( node, "length", 0 );

                ProfileController.AddPropertyDefinition( objProfileDefinition );
            }
        }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Determines whether the collection contains a property definition
 /// </summary>
 /// <param name="value">A ProfilePropertyDefinition object</param>
 /// <returns>A Boolean True/False</returns>
 /// -----------------------------------------------------------------------------
 public bool Contains(ProfilePropertyDefinition value)
 {
     return(List.Contains(value));
 }
예제 #43
0
        private static ProfilePropertyDefinition FillPropertyDefinitionInfo(IDataReader dr, bool checkForOpenDataReader)
        {
            ProfilePropertyDefinition definition = null;

            //read datareader
            bool canContinue = true;
            if (checkForOpenDataReader)
            {
                canContinue = false;
                if (dr.Read())
                {
                    canContinue = true;
                }
            }
            if (canContinue)
            {
                int portalid = 0;
                portalid = Convert.ToInt32(Null.SetNull(dr["PortalId"], portalid));
                definition = new ProfilePropertyDefinition(portalid);
                definition.PropertyDefinitionId = Convert.ToInt32(Null.SetNull(dr["PropertyDefinitionId"], definition.PropertyDefinitionId));
                definition.ModuleDefId = Convert.ToInt32(Null.SetNull(dr["ModuleDefId"], definition.ModuleDefId));
                definition.DataType = Convert.ToInt32(Null.SetNull(dr["DataType"], definition.DataType));
                definition.DefaultValue = Convert.ToString(Null.SetNull(dr["DefaultValue"], definition.DefaultValue));
                definition.PropertyCategory = Convert.ToString(Null.SetNull(dr["PropertyCategory"], definition.PropertyCategory));
                definition.PropertyName = Convert.ToString(Null.SetNull(dr["PropertyName"], definition.PropertyName));
                definition.Length = Convert.ToInt32(Null.SetNull(dr["Length"], definition.Length));
                if (dr.GetSchemaTable().Select("ColumnName = 'ReadOnly'").Length > 0)
                {
                    definition.ReadOnly = Convert.ToBoolean(Null.SetNull(dr["ReadOnly"], definition.ReadOnly));
                }
                definition.Required = Convert.ToBoolean(Null.SetNull(dr["Required"], definition.Required));
                definition.ValidationExpression = Convert.ToString(Null.SetNull(dr["ValidationExpression"], definition.ValidationExpression));
                definition.ViewOrder = Convert.ToInt32(Null.SetNull(dr["ViewOrder"], definition.ViewOrder));
                definition.Visible = Convert.ToBoolean(Null.SetNull(dr["Visible"], definition.Visible));
                definition.DefaultVisibility = (UserVisibilityMode) Convert.ToInt32(Null.SetNull(dr["DefaultVisibility"], definition.DefaultVisibility));
                definition.ProfileVisibility = new ProfileVisibility
                                                   {
                                                       VisibilityMode = definition.DefaultVisibility
                                                   };
                definition.Deleted = Convert.ToBoolean(Null.SetNull(dr["Deleted"], definition.Deleted));
            }
            return definition;
        }
예제 #44
0
        /// <summary>
        /// Adds a single default property definition
        /// </summary>
        /// <param name="PortalId">Id of the Portal</param>
        /// <param name="category">Category of the Property</param>
        /// <param name="name">Name of the Property</param>
        private static void AddDefaultDefinition(int PortalId, string category, string name, string strType, int length, ListEntryInfoCollection types)
        {
            ListEntryInfo typeInfo = types.Item("DataType." + strType);
            if (typeInfo == null)
            {
                typeInfo = types.Item("DataType.Unknown");
            }

            ProfilePropertyDefinition propertyDefinition = new ProfilePropertyDefinition();
            propertyDefinition.DataType = typeInfo.EntryID;
            propertyDefinition.DefaultValue = "";
            propertyDefinition.ModuleDefId = Null.NullInteger;
            propertyDefinition.PortalId = PortalId;
            propertyDefinition.PropertyCategory = category;
            propertyDefinition.PropertyName = name;
            propertyDefinition.Required = false;
            propertyDefinition.Visible = true;
            propertyDefinition.Length = length;

            _orderCounter += 2;

            propertyDefinition.ViewOrder = _orderCounter;

            AddPropertyDefinition(propertyDefinition);
        }
예제 #45
0
        public void DateTimePropertyAcccess_GetProperty_Adjusts_For_TimeZone(string propertyName, string timeZoneId)
        {
            //Arrange
            var dtPropertyAccess = new DateTimePropertyAccess();
            var userTimeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId);
            var timeZoneProfileProperty = new ProfilePropertyDefinition(Constants.PORTAL_Zero)
                                              {
                                                  PropertyName = "PreferredTimeZone",
                                                  PropertyValue = timeZoneId
                                              };
            var userProfile = new UserProfile();
            userProfile.ProfileProperties.Add(timeZoneProfileProperty);

            var accessingUser = new UserInfo { Profile = userProfile };
            var culture = CultureInfo.InvariantCulture;

            string expected = String.Empty;

            switch (propertyName)
            {
                case "current":
                    expected = TimeZoneInfo.ConvertTime(DateTime.Now, userTimeZone).ToString("D", culture);
                    break;
                case "now":
                    expected = TimeZoneInfo.ConvertTime(DateTime.Now, userTimeZone).ToString("g", culture);
                    break;
                case "system":
                    expected = DateTime.Now.ToString("g", culture);
                    break;
                case "utc":
                    expected = DateTime.Now.ToUniversalTime().ToString("g", culture);
                    break;
            }


            //Act
            bool propertyNotFound = false;
            string propertyValue = dtPropertyAccess.GetProperty(propertyName, "", culture,
                                                                   accessingUser, Scope.DefaultSettings, ref propertyNotFound);

            //Assert
            Assert.AreEqual(expected, propertyValue);
        }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Inserts a property Definition into the collectio.
 /// </summary>
 /// <param name="value">A ProfilePropertyDefinition object</param>
 /// <param name="index">The index to insert the item at</param>
 /// -----------------------------------------------------------------------------
 public void Insert(int index, ProfilePropertyDefinition value)
 {
     List.Insert(index, value);
 }
예제 #47
0
 public static string GetRichValue(ProfilePropertyDefinition property, string formatString, CultureInfo formatProvider)
 {
     string result = "";
     if (!String.IsNullOrEmpty(property.PropertyValue) || DisplayDataType(property).ToLower() == "image")
     {
         switch (DisplayDataType(property).ToLower())
         {
             case "truefalse":
                 result = PropertyAccess.Boolean2LocalizedYesNo(Convert.ToBoolean(property.PropertyValue), formatProvider);
                 break;
             case "date":
             case "datetime":
                 if (formatString == string.Empty)
                 {
                     formatString = "g";
                 }
                 result = DateTime.Parse(property.PropertyValue, CultureInfo.InvariantCulture).ToString(formatString, formatProvider);
                 break;
             case "integer":
                 if (formatString == string.Empty)
                 {
                     formatString = "g";
                 }
                 result = int.Parse(property.PropertyValue).ToString(formatString, formatProvider);
                 break;
             case "page":
                 var tabCtrl = new TabController();
                 int tabid;
                 if (int.TryParse(property.PropertyValue, out tabid))
                 {
                     TabInfo tab = tabCtrl.GetTab(tabid, Null.NullInteger, false);
                     if (tab != null)
                     {
                         result = string.Format("<a href='{0}'>{1}</a>", Globals.NavigateURL(tabid), tab.LocalizedTabName);
                     }
                 }
                 break;
             case "image":
                 //File is stored as a FileID
                 int fileID;
                 if (Int32.TryParse(property.PropertyValue, out fileID) && fileID > 0)
                 {
                     result = Globals.LinkClick(String.Format("fileid={0}", fileID), Null.NullInteger, Null.NullInteger);
                 }
                 else
                 {
                     result = IconController.IconURL("Spacer","1X1");
                 }
                 break;
             case "richtext":
                 var objSecurity = new PortalSecurity();
                 result = PropertyAccess.FormatString(objSecurity.InputFilter(HttpUtility.HtmlDecode(property.PropertyValue), PortalSecurity.FilterFlag.NoScripting), formatString);
                 break;
             default:
                 result = HttpUtility.HtmlEncode(PropertyAccess.FormatString(property.PropertyValue, formatString));
                 break;
         }
     }
     return result;
 }
예제 #48
0
 /// <summary>
 /// Adds a Property Defintion to the Data Store
 /// </summary>
 /// <param name="definition">An ProfilePropertyDefinition object</param>
 /// <returns>The Id of the definition (or if negative the errorcode of the error)</returns>
 public static int AddPropertyDefinition(ProfilePropertyDefinition definition)
 {
     return(provider.AddPropertyDefinition(definition.PortalId, definition.ModuleDefId, definition.DataType, definition.DefaultValue, definition.PropertyCategory, definition.PropertyName, definition.Required, definition.ValidationExpression, definition.ViewOrder, definition.Visible, definition.Length));
 }
 /// <summary>
 /// Clone a ProfilePropertyDefinition
 /// </summary>
 /// <returns>A ProfilePropertyDefinition</returns>
 public ProfilePropertyDefinition Clone()
 {
     var clone = new ProfilePropertyDefinition(PortalId)
                     {
                         DataType = DataType,
                         DefaultValue = DefaultValue,
                         Length = Length,
                         ModuleDefId = ModuleDefId,
                         PropertyCategory = PropertyCategory,
                         PropertyDefinitionId = PropertyDefinitionId,
                         PropertyName = PropertyName,
                         PropertyValue = PropertyValue,
                         ReadOnly = ReadOnly,
                         Required = Required,
                         ValidationExpression = ValidationExpression,
                         ViewOrder = ViewOrder,
                         DefaultVisibility = DefaultVisibility,
                         ProfileVisibility = ProfileVisibility.Clone(),
                         Visible = Visible,
                         Deleted = Deleted
                     };
     clone.ClearIsDirty();
     return clone;
 }
예제 #50
0
 /// <summary>
 /// Updates a Property Defintion in the Data Store
 /// </summary>
 /// <param name="definition">The ProfilePropertyDefinition object to update</param>
 public static void UpdatePropertyDefinition(ProfilePropertyDefinition definition)
 {
     provider.UpdatePropertyDefinition(definition.PropertyDefinitionId, definition.DataType, definition.DefaultValue, definition.PropertyCategory, definition.PropertyName, definition.Required, definition.ValidationExpression, definition.ViewOrder, definition.Visible, definition.Length);
 }
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ExportModule implements the IPortable ExportModule Interface
        /// </summary>
        /// <param name="ModuleID">The Id of the module to be exported</param>
        /// -----------------------------------------------------------------------------
        //public string ExportModule(int ModuleID)
        //{
        //string strXML = "";
        //List<DNNVideoCourseInfo> colDNNVideoCourses = GetDNNVideoCourses(ModuleID);
        //if (colDNNVideoCourses.Count != 0)
        //{
        //    strXML += "<DNNVideoCourses>";
        //    foreach (DNNVideoCourseInfo objDNNVideoCourse in colDNNVideoCourses)
        //    {
        //        strXML += "<DNNVideoCourse>";
        //        strXML += "<content>" + DotNetNuke.Common.Utilities.XmlUtils.XMLEncode(objDNNVideoCourse.Content) + "</content>";
        //        strXML += "</DNNVideoCourse>";
        //    }
        //    strXML += "</DNNVideoCourses>";
        //}
        //return strXML;
        //    throw new System.NotImplementedException("The method or operation is not implemented.");
        //}
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ImportModule implements the IPortable ImportModule Interface
        /// </summary>
        /// <param name="ModuleID">The Id of the module to be imported</param>
        /// <param name="Content">The content to be imported</param>
        /// <param name="Version">The version of the module to be imported</param>
        /// <param name="UserId">The Id of the user performing the import</param>
        /// -----------------------------------------------------------------------------
        //public void ImportModule(int ModuleID, string Content, string Version, int UserID)
        //{
        //XmlNode xmlDNNVideoCourses = DotNetNuke.Common.Globals.GetContent(Content, "DNNVideoCourses");
        //foreach (XmlNode xmlDNNVideoCourse in xmlDNNVideoCourses.SelectNodes("DNNVideoCourse"))
        //{
        //    DNNVideoCourseInfo objDNNVideoCourse = new DNNVideoCourseInfo();
        //    objDNNVideoCourse.ModuleId = ModuleID;
        //    objDNNVideoCourse.Content = xmlDNNVideoCourse.SelectSingleNode("content").InnerText;
        //    objDNNVideoCourse.CreatedByUser = UserID;
        //    AddDNNVideoCourse(objDNNVideoCourse);
        //}
        //    throw new System.NotImplementedException("The method or operation is not implemented.");
        //}
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// GetSearchItems implements the ISearchable Interface
        /// </summary>
        /// <param name="ModInfo">The ModuleInfo for the module to be Indexed</param>
        /// -----------------------------------------------------------------------------
        //public DotNetNuke.Services.Search.SearchItemInfoCollection GetSearchItems(DotNetNuke.Entities.Modules.ModuleInfo ModInfo)
        //{
        //SearchItemInfoCollection SearchItemCollection = new SearchItemInfoCollection();
        //List<DNNVideoCourseInfo> colDNNVideoCourses = GetDNNVideoCourses(ModInfo.ModuleID);
        //foreach (DNNVideoCourseInfo objDNNVideoCourse in colDNNVideoCourses)
        //{
        //    SearchItemInfo SearchItem = new SearchItemInfo(ModInfo.ModuleTitle, objDNNVideoCourse.Content, objDNNVideoCourse.CreatedByUser, objDNNVideoCourse.CreatedDate, ModInfo.ModuleID, objDNNVideoCourse.videoId.ToString(), objDNNVideoCourse.Content, "videoId=" + objDNNVideoCourse.videoId.ToString());
        //    SearchItemCollection.Add(SearchItem);
        //}
        //return SearchItemCollection;
        //    throw new System.NotImplementedException("The method or operation is not implemented.");
        //}
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// UpgradeModule implements the IUpgradeable Interface
        /// </summary>
        /// <param name="Version">The current version of the module</param>
        /// -----------------------------------------------------------------------------
        public string UpgradeModule(string Version)
        {
            // these could be constants instead, but this code will very rarely be run and won't be run at such scale that it will matter that much
            var goodResult = "true";
            var badResult = "false";
            var propertyCategory = "Video Module Status";
            var propertyName = "videosComplete";

            switch (Version)
            {
                case "01.00.06": // should be whichever version number is being upgraded to or currently installed
                    try
                    {
                        // get a collection of portals to iterate through
                        var portals = PortalController.Instance.GetPortals();

                        // update each portal since they could each potentially use the module and we'll have no idea which one already is or will be later
                        foreach (PortalInfo portal in portals)
                        {
                            var pdef = ProfileController.GetPropertyDefinitionByName(portal.PortalID, propertyName);

                            if (pdef == null)
                            {
                                // Create the profile property programatically or throw error
                                var newProfile = new ProfilePropertyDefinition(portal.PortalID);
                                newProfile.PortalId = portal.PortalID;
                                newProfile.ModuleDefId = Null.NullInteger;
                                newProfile.DataType = 349;
                                newProfile.DefaultValue = string.Empty;
                                newProfile.PropertyCategory = propertyCategory; // made this a static object above to save memory for performance if there are lot of portals
                                newProfile.PropertyName = propertyName; // made this a static object above to save memory for performance if there are lot of portals
                                newProfile.ReadOnly = true;
                                newProfile.Required = false;
                                newProfile.Visible = false;
                                newProfile.Length = 0;
                                newProfile.DefaultVisibility = UserVisibilityMode.AllUsers;

                                ProfileController.AddPropertyDefinition(newProfile);
                            }
                        }

                        return goodResult;
                    }
                    catch
                    {
                        // attempting to report the exception here is useless, because DNN will never log it anywhere for some reason
                        return badResult;
                    }
                default:
                    return goodResult;
            }
        }
        public string DisplayDataType( ProfilePropertyDefinition definition )
        {
            string retValue = Null.NullString;
            ListController objListController = new ListController();
            ListEntryInfo definitionEntry = objListController.GetListEntryInfo( definition.DataType );

            if( definitionEntry != null )
            {
                retValue = definitionEntry.Value;
            }

            return retValue;
        }
예제 #53
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Updates a Property Defintion in the Data Store
 /// </summary>
 /// <param name="definition">The ProfilePropertyDefinition object to update</param>
 /// -----------------------------------------------------------------------------
 public static void UpdatePropertyDefinition(ProfilePropertyDefinition definition)
 {
     
     if (definition.Required)
     {
         definition.Visible = true;
     }
     _dataProvider.UpdatePropertyDefinition(definition.PropertyDefinitionId,
                                       definition.DataType,
                                       definition.DefaultValue,
                                       definition.PropertyCategory,
                                       definition.PropertyName,
                                       definition.ReadOnly,
                                       definition.Required,
                                       definition.ValidationExpression,
                                       definition.ViewOrder,
                                       definition.Visible,
                                       definition.Length,
                                       (int) definition.DefaultVisibility,
                                       UserController.GetCurrentUserInfo().UserID);
     var objEventLog = new EventLogController();
     objEventLog.AddLog(definition, PortalController.GetCurrentPortalSettings(), UserController.GetCurrentUserInfo().UserID, "", EventLogController.EventLogType.PROFILEPROPERTY_UPDATED);
     ClearProfileDefinitionCache(definition.PortalId);
 }