Beispiel #1
0
        private static void CheckRankUpDown(Member user, int checkReferrerLevels = 0)
        {
            if (!AppSettings.TitanFeatures.LeaderShipSystemEnabled)
            {
                return;
            }

            RanksUsers currentRank = RanksUsers.GetCurrentUserRank(user.Id);
            int        newRankId   = -1;

            LeadershipRank rank = null;

            if (currentRank == null)
            {
                rank = LeadershipRank.GetFirst();

                if (rank != null && LeadershipRank.IsRankAccured(rank.Id, user))
                {
                    RanksUsers.UpdateRank(rank.Id, user.Id);
                    currentRank = RanksUsers.GetByRankId(user.Id, rank.Id);
                }
                else
                {
                    return;
                }
            }

            rank = new LeadershipRank(currentRank.RankId);
            if (!LeadershipRank.IsRankAccured(rank.Id, user))
            {
                newRankId = CheckRankDown(user, rank);
            }
            else
            {
                newRankId = CheckRankUp(user, rank);
            }

            RanksUsers newRank = RanksUsers.GetByRankId(user.Id, newRankId);

            if (newRank != null)
            {
                newRank.SetCurrent();
            }
            else
            {
                RanksUsers.SetRankZero(user.Id);
            }

            if (checkReferrerLevels > 0 && user.HasReferer && LeadershipRankRequirements.HaveToCheckDirectReferral())
            {
                CheckRankUpDown(new Member(user.ReferrerId), --checkReferrerLevels);
            }
        }
Beispiel #2
0
        public static void CheckSystem(List <RestrictionKind> restriction, Member user, int checkReferrerLevels = 0)
        {
            if (!AppSettings.TitanFeatures.LeaderShipSystemEnabled)
            {
                return;
            }
            var list = LeadershipRankRequirements.RequirementsList;

            for (int i = 0; i < list.Count; i++)
            {
                if (restriction.Contains(list[i].RestrictionKind))
                {
                    CheckRankUpDown(user);
                    if (checkReferrerLevels > 0 && user.HasReferer && LeadershipRankRequirements.HaveToCheckDirectReferral())
                    {
                        CheckRankUpDown(new Member(user.ReferrerId), --checkReferrerLevels);
                    }
                    break;
                }
            }

            LeadershipRank.DeletePausedIfPossible();
        }