예제 #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);
            }
        }
예제 #2
0
        public void RemoveRestriction(int Id)
        {
            var restriction = new LeadershipRankRequirements(Id);

            if (restriction != null)
            {
                if (HasOnlyOneRequirement(restriction.Rank))
                {
                    throw new MsgException("You can't remove this Requirement. It's last for this rank. If you want to remove rank use Rank tab.");
                }

                restriction.Delete();
            }
        }
예제 #3
0
        public void UpdateRankStatus(UniversalStatus status)
        {
            LeadershipRankRequirements.UpdateRankStatus(this.Id, status);

            Dictionary <string, object> updateSet = new Dictionary <string, object>();

            updateSet.Add(Columns.RankStatus, (int)status);

            if (status == UniversalStatus.Deleted)
            {
                updateSet.Add(Columns.PrevRankId, -2);
                updateSet.Add(Columns.NextRankId, -2);

                this.ReorderIds();
            }

            Dictionary <string, object> updateWhere = new Dictionary <string, object>();

            updateWhere.Add(Columns.Id, this.Id);

            TableHelper.UpdateRows(TableName, updateSet, updateWhere);
        }
예제 #4
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();
        }
예제 #5
0
 public void AddRestriction(int rank, RestrictionKind restriction, int value)
 {
     var newRestriction = new LeadershipRankRequirements(rank, restriction, value);
 }