示例#1
0
        public User(Core core, DataRow userRow)
            : base(core)
        {
            UserLoadOptions loadOptions = UserLoadOptions.All;
            ItemLoad += new ItemLoadHandler(User_ItemLoad);

            if (userRow != null)
            {
                loadItemInfo(typeof(User), userRow);

                if ((loadOptions & UserLoadOptions.Info) == UserLoadOptions.Info)
                {
                    userInfo = new UserInfo(core, userRow);
                }

                if ((loadOptions & UserLoadOptions.Profile) == UserLoadOptions.Profile)
                {
                    userProfile = new UserProfile(core, this, userRow, loadOptions);
                }
            }
            else
            {
                throw new InvalidUserException();
            }
        }
示例#2
0
        public User(Core core, System.Data.Common.DbDataReader userRow, UserLoadOptions loadOptions)
            : base(core)
        {
            ItemLoad += new ItemLoadHandler(User_ItemLoad);

            if (userRow != null)
            {
                loadItemInfo(typeof(User), userRow);

                if ((loadOptions & UserLoadOptions.Info) == UserLoadOptions.Info)
                {
                    userInfo = new UserInfo(core, userRow);
                }

                if ((loadOptions & UserLoadOptions.Profile) == UserLoadOptions.Profile)
                {
                    userProfile = new UserProfile(core, this, userRow, loadOptions);
                }
            }
            else
            {
                throw new InvalidUserException();
            }
        }
示例#3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="userRow"></param>
        protected void loadUserProfile(DataRow userRow)
        {
            // use the user's timezone, after all it is _their_ birthday
            //dateOfBirth = GetTimeZone.DateTimeFromMysql(userRow["profile_date_of_birth_ut"]);

            userProfile = new UserProfile(core, this, userRow);
        }
示例#4
0
        protected void loadUserFromUser(User member)
        {
            this.userId = member.userId;
            this.userName = member.userName;

            this.userInfo = member.userInfo;
            this.userProfile = member.userProfile;

            this.userIconUri = member.userIconUri;
        }
示例#5
0
 public void LoadProfileInfo()
 {
     if (userProfile == null)
     {
         userProfile = new UserProfile(core, this);
     }
 }
示例#6
0
        public User(Core core, string userName, UserLoadOptions loadOptions)
            : base(core)
        {
            ItemLoad += new ItemLoadHandler(User_ItemLoad);

            bool containsInfoData = false;
            bool containsProfileData = false;
            bool containsIconData = false;

            if (loadOptions == UserLoadOptions.Key)
            {
                try
                {
                    LoadItem("user_name_lower", userName.ToLower(), true);
                }
                catch (InvalidItemException)
                {
                    throw new InvalidUserException();
                }
            }
            else
            {
                SelectQuery query = new SelectQuery(User.GetTable(typeof(User)));
                query.AddFields(User.GetFieldsPrefixed(core, typeof(User)));
                query.AddCondition(new DataField("user_keys", "user_name_lower"), userName.ToLower());

                if ((loadOptions & UserLoadOptions.Info) == UserLoadOptions.Info)
                {
                    containsInfoData = true;

                    query.AddJoin(JoinTypes.Inner, UserInfo.GetTable(typeof(UserInfo)), "user_id", "user_id");
                    query.AddFields(UserInfo.GetFieldsPrefixed(core, typeof(UserInfo)));

                    /*if ((loadOptions & UserLoadOptions.Icon) == UserLoadOptions.Icon)
                    {
                        containsIconData = true;

                        query.AddJoin(JoinTypes.Left, new DataField("user_info", "user_icon"), new DataField("gallery_items", "gallery_item_id"));
                        query.AddField(new DataField("gallery_items", "gallery_item_uri"));
                        query.AddField(new DataField("gallery_items", "gallery_item_parent_path"));
                    }*/
                }

                if ((loadOptions & UserLoadOptions.Profile) == UserLoadOptions.Profile)
                {
                    containsProfileData = true;

                    query.AddJoin(JoinTypes.Inner, UserProfile.GetTable(typeof(UserProfile)), "user_id", "user_id");
                    query.AddFields(UserProfile.GetFieldsPrefixed(core, typeof(UserProfile)));

                    if ((loadOptions & UserLoadOptions.Country) == UserLoadOptions.Country)
                    {
                        query.AddJoin(JoinTypes.Left, new DataField("user_profile", "profile_country"), new DataField("countries", "country_iso"));
                    }

                    if ((loadOptions & UserLoadOptions.Religion) == UserLoadOptions.Religion)
                    {
                        query.AddJoin(JoinTypes.Left, new DataField("user_profile", "profile_religion"), new DataField("religions", "religion_id"));
                    }
                }

                DataTable memberTable = db.Query(query);

                if (memberTable.Rows.Count > 0)
                {
                    loadItemInfo(typeof(User), memberTable.Rows[0]);

                    if (containsInfoData)
                    {
                        userInfo = new UserInfo(core, memberTable.Rows[0]);
                    }

                    if (containsProfileData)
                    {
                        userProfile = new UserProfile(core, this, memberTable.Rows[0], loadOptions);
                    }

                    if (containsIconData)
                    {
                        loadUserIcon(memberTable.Rows[0]);
                    }
                }
                else
                {
                    throw new InvalidUserException();
                }
            }
        }
示例#7
0
        public ForumMember(Core core, Primitive owner, long userId, UserLoadOptions loadOptions)
            : base(core)
        {
            ItemLoad += new ItemLoadHandler(ForumMember_ItemLoad);

            SelectQuery query = GetSelectQueryStub(core, UserLoadOptions.All);
            query.AddCondition("user_keys.user_id", userId);
            query.AddCondition("item_id", owner.Id);
            query.AddCondition("item_type_id", owner.TypeId);

            DataTable memberTable = db.Query(query);

            if (memberTable.Rows.Count == 1)
            {
                DataRow userRow = memberTable.Rows[0];

                loadItemInfo(userRow);
                loadItemInfo(typeof(User), userRow);

                if ((loadOptions & UserLoadOptions.Info) == UserLoadOptions.Info)
                {
                    userInfo = new UserInfo(core, userRow);
                }

                if ((loadOptions & UserLoadOptions.Profile) == UserLoadOptions.Profile)
                {
                    userProfile = new UserProfile(core, this, userRow, loadOptions);
                }

                /*if ((loadOptions & UserLoadOptions.Icon) == UserLoadOptions.Icon)
                {
                    loadUserIcon(userRow);
                }*/
            }
            else
            {
                throw new InvalidUserException();
            }
        }