Пример #1
0
	/**
	 * Checks whether this user is allowed to send these emails or not.
	 *
	 * @param object $user_object User Object to check.
	 * @param int    $queuesize   The size of the queue to check.
	 * @param int    $queuetime   The time when you are trying to send / schedule the queue.
	 *
	 * @return array Returns an array of status and a language variable describing why it can't be sent. This allows us to differentiate between whether it's a "maxemails" issue or a "per month" issue.
	 */
	public function CheckUserStats(User_API $user, $queueSize = 0, $queuetime=0)
	{
                // if they have no limits, then no need to do any other checks
		if ($user->hasUnlimitedCredit()) {return array(true, false);}

		$queueSize = (int) $queueSize;
                
		if (!$user->hasUnlimitedMonthlyCredit()){
                    $monthly = (int) API_USERS::creditAvailableThisMonth($user->userid, false, $queuetime);
                }
                
                if (!$user->hasUnlimitedTotalCredit()){
                    $total = (int) API_USERS::creditAvailableFixed($user->userid);
                }
                
		// do monthly credit check
		if (isset($monthly) && $queueSize > $monthly){return array(false, 'OverLimit_PerMonth');}

		// do total credit check
		if (isset($total) && $queueSize > $total) {return array(false, 'OverLimit_MaxEmails');}

		return array(true, false);
	}