예제 #1
0
파일: user.php 프로젝트: hungnv0789/vhtm
    /**
     * GetAvailableEmailsThisMonth
     * Returns the number of emails you can send "this month" based on how many you have already sent.
     *
     * This is different to "permonth" because that number doesn't get adjusted as you send out (otherwise we'd need an extra db field to store the "original" info and the adjusted info).
     *
     * Returns -1 if the user hasn't been loaded, or if the per month limit is set to 0.
     *
     * @return Int Returns the number you can send left "this month" (and this month only).
     */
    function GetAvailableEmailsThisMonth() {
        trigger_error(__CLASS__ . '::' . __METHOD__ . 'This function is deprecated. Please use API_USERS::* instead', E_USER_NOTICE);

        return API_USERS::creditAvailableThisMonth($this->userid);
    }
예제 #2
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);
	}