本文整理汇总了PHP中myPartnerUtils::notifiyPartner方法的典型用法代码示例。如果您正苦于以下问题:PHP myPartnerUtils::notifiyPartner方法的具体用法?PHP myPartnerUtils::notifiyPartner怎么用?PHP myPartnerUtils::notifiyPartner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类myPartnerUtils
的用法示例。
在下文中一共展示了myPartnerUtils::notifiyPartner方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validatePartnerMonthlyUsagePerType
private static function validatePartnerMonthlyUsagePerType($partner, $partnerPackage, $usage, $usageType, $report_date, $block_notification_grace, $delete_grace, $email_link_hash)
{
if (!array_key_exists($usageType, $partnerPackage)) {
return;
}
$usageGB = $usage / 1024 / 1024;
// from KB to GB
$percent = round($usageGB / $partnerPackage[$usageType] * 100, 2);
$notificationId = 0;
KalturaLog::debug("percent (" . $partner->getId() . ") is: {$percent} for usage type {$usageType}");
//check if partner should be deleted
if ($partner->getStatus() == Partner::PARTNER_STATUS_CONTENT_BLOCK) {
$warning_100 = $partner->getUsageWarning($usageType, 100);
if ($warning_100 > 0 && $warning_100 <= $delete_grace) {
KalturaLog::debug("partner " . $partner->getId() . " reached 100% a month ago - deleting partner");
/* delete partner */
$notificationId = myPartnerUtils::KALTURA_DELETE_ACCOUNT;
$partner->setStatus(Partner::PARTNER_STATUS_DELETED);
}
} else {
self::resetMonthlyUsageWarningIfNotRelevant($partner, $usageType, $percent, $report_date);
$warning_80 = $partner->getUsageWarning($usageType, 80);
$warning_100 = $partner->getUsageWarning($usageType, 100);
if ($percent >= 80 && $percent < 100 && !$warning_80) {
KalturaLog::debug("partner " . $partner->getId() . " reached 80% - setting first warning for usage " . $usageType);
$partner->setUsageWarning($usageType, 80, time());
$partner->resetUsageWarning($usageType, 100);
$notificationId = myPartnerUtils::KALTURA_MONTHLY_PACKAGE_EIGHTY_PERCENT_WARNING;
} elseif ($percent >= 80 && $percent < 100 && $warning_80 && !$warning_100) {
KalturaLog::log("passed the 80%, assume notification sent, nothing to do.");
} elseif ($percent >= 100 && !$warning_100) {
KalturaLog::debug("partner " . $partner->getId() . " reached 100% - setting second warning for usage " . $usageType);
$partner->setUsageWarning($usageType, 100, time());
$notificationId = myPartnerUtils::KALTURA_MONTHLY_PACKAGE_LIMIT_WARNING_1;
} elseif ($percent >= 100 && $warning_100 > 0 && $warning_100 <= $block_notification_grace && $warning_100 > $delete_grace) {
KalturaLog::debug("partner " . $partner->getId() . " reached 100% " . self::BLOCKING_DAYS_GRACE . " days ago - sending block email and blocking partner");
/* send block email and block partner */
$notificationId = myPartnerUtils::KALTURA_MONTHLY_PACKAGE_LIMIT_WARNING_2;
$partner->setStatus(Partner::PARTNER_STATUS_CONTENT_BLOCK);
}
}
if ($notificationId) {
$body_params = array();
$usageText = PartnerPackages::getPackageUsageText($usageType);
switch ($notificationId) {
case myPartnerUtils::KALTURA_MONTHLY_PACKAGE_EIGHTY_PERCENT_WARNING:
$body_params = array($partner->getAdminName(), $partnerPackage[$usageType], $usageText, round($usageGB, 2), $email_link_hash);
break;
case myPartnerUtils::KALTURA_MONTHLY_PACKAGE_LIMIT_WARNING_1:
$body_params = array($partner->getAdminName(), $partnerPackage[$usageType], $usageText, round($usageGB, 2), $email_link_hash);
break;
case myPartnerUtils::KALTURA_MONTHLY_PACKAGE_LIMIT_WARNING_2:
$body_params = array($partner->getAdminName(), $partnerPackage[$usageType], $usageText, round($usageGB, 2), $email_link_hash);
break;
case myPartnerUtils::KALTURA_DELETE_ACCOUNT:
$body_params = array($partner->getAdminName());
break;
}
myPartnerUtils::notifiyPartner($notificationId, $partner, $body_params);
}
}
示例2: doPartnerUsage
public static function doPartnerUsage(Partner $partner)
{
if ($partner->getExtendedFreeTrail()) {
if ($partner->getExtendedFreeTrailExpiryDate() < time()) {
//ExtendedFreeTrail ended
$partner->setExtendedFreeTrail(null);
$partner->setExtendedFreeTrailExpiryDate(null);
$partner->setExtendedFreeTrailExpiryReason('');
} else {
//ExtendedFreeTrail
if ($partner->getExtendedFreeTrailExpiryDate() < time() + dateUtils::DAY * 7 && !$partner->getExtendedFreeTrailEndsWarning()) {
$partner->setExtendedFreeTrailEndsWarning(true);
$partner->save();
$email_link_hash = 'pid=' . $partner->getId() . '&h=' . self::getEmailLinkHash($partner->getId(), $partner->getSecret());
$mail_parmas = array($partner->getAdminName(), $email_link_hash);
myPartnerUtils::notifiyPartner(myPartnerUtils::KALTURA_EXTENED_FREE_TRAIL_ENDS_WARNING, $partner, $mail_parmas);
}
return;
}
}
$should_block_delete_partner = true;
$blocking_days_grace = 7;
$block_notification_grace = time() - dateUtils::DAY * $blocking_days_grace;
$delete_grace = time() - dateUtils::DAY * 30;
$packages = new PartnerPackages();
$partnerPackage = $packages->getPackageDetails($partner->getPartnerPackage());
$report_date = date('Y-m') . '-01';
// We are now working with the DWH and a stored-procedure, and not with record type 6 on partner_activity.
$report_date = dateUtils::todayOffset(-1);
list($totalStorage, $totalUsage, $totalTraffic) = myPartnerUtils::collectPartnerStatisticsFromDWH($partner, $partnerPackage, $report_date);
$totalUsageGB = $totalUsage / 1024 / 1024;
// from KB to GB
$percent = round($totalUsageGB / $partnerPackage['cycle_bw'] * 100, 2);
KalturaLog::debug("percent (" . $partner->getId() . ") is: {$percent}");
$email_link_hash = 'pid=' . $partner->getId() . '&h=' . self::getEmailLinkHash($partner->getId(), $partner->getSecret());
$email_link_hash_adOpt = $email_link_hash . '&type=adOptIn';
/* mindtouch partners - extra mail parameter */
$mindtouch_notice = ' ';
if ($partner->getType() == 103) {
$mindtouch_notice = '<BR><BR>Note: You must be a MindTouch paying customer to upgrade your video service. If you are not a paying MindTouch customer, contact MindTouch: http://www.mindtouch.com/about_mindtouch/contact_mindtouch to get a quote.<BR><BR>';
}
if ($percent >= 80 && $percent < 100 && !$partner->getEightyPercentWarning()) {
KalturaLog::debug("partner " . $partner->getId() . " reached 80% - setting first warning");
/* prepare mail job, and set EightyPercentWarning() to true/date */
$partner->setEightyPercentWarning(time());
$partner->setUsageLimitWarning(0);
$body_params = array($partner->getAdminName(), $partnerPackage['cycle_bw'], $mindtouch_notice, round($totalUsageGB, 2), $email_link_hash);
myPartnerUtils::notifiyPartner(myPartnerUtils::KALTURA_PACKAGE_EIGHTY_PERCENT_WARNING, $partner, $body_params);
} elseif ($percent >= 80 && $percent < 100 && $partner->getEightyPercentWarning() && !$partner->getUsageLimitWarning()) {
KalturaLog::debug("passed the 80%, assume notification sent, nothing to do.");
} elseif ($percent < 80 && $partner->getEightyPercentWarning()) {
KalturaLog::debug("partner " . $partner->getId() . " was 80%, now not. clearing warnings");
/* clear getEightyPercentWarning */
$partner->setEightyPercentWarning(0);
$partner->setUsageLimitWarning(0);
} elseif ($percent >= 100 && !$partner->getUsageLimitWarning()) {
KalturaLog::debug("partner " . $partner->getId() . " reached 100% - setting second warning");
/* prepare mail job, and set getUsageLimitWarning() date */
$partner->setUsageLimitWarning(time());
$body_params = array($partner->getAdminName(), $mindtouch_notice, round($totalUsageGB, 2), $email_link_hash);
myPartnerUtils::notifiyPartner(myPartnerUtils::KALTURA_PACKAGE_LIMIT_WARNING_1, $partner, $body_params);
} elseif ($percent >= 100 && $partnerPackage['cycle_fee'] == 0 && $partner->getUsageLimitWarning() > 0 && $partner->getUsageLimitWarning() <= $block_notification_grace && $partner->getUsageLimitWarning() > $delete_grace && $partner->getStatus() != Partner::PARTNER_STATUS_CONTENT_BLOCK) {
KalturaLog::debug("partner " . $partner->getId() . " reached 100% {$blocking_days_grace} days ago - sending block email and blocking partner");
/* send block email and block partner */
$body_params = array($partner->getAdminName(), $mindtouch_notice, round($totalUsageGB, 2), $email_link_hash);
myPartnerUtils::notifiyPartner(myPartnerUtils::KALTURA_PACKAGE_LIMIT_WARNING_2, $partner, $body_params);
if ($should_block_delete_partner) {
$partner->setStatus(Partner::PARTNER_STATUS_CONTENT_BLOCK);
}
} elseif ($percent >= 120 && $partnerPackage['cycle_fee'] != 0 && $partner->getUsageLimitWarning() <= $block_notification_grace) {
$body_params = array($partner->getAdminName(), round($totalUsageGB, 2));
myPartnerUtils::notifiyPartner(myPartnerUtils::KALTURA_PAID_PACKAGE_SUGGEST_UPGRADE, $partner, $body_params);
} elseif ($percent >= 100 && $partnerPackage['cycle_fee'] == 0 && $partner->getUsageLimitWarning() > 0 && $partner->getUsageLimitWarning() <= $delete_grace && $partner->getStatus() == Partner::PARTNER_STATUS_CONTENT_BLOCK) {
KalturaLog::debug("partner " . $partner->getId() . " reached 100% a month ago - deleting partner");
/* delete partner */
$body_params = array($partner->getAdminName());
myPartnerUtils::notifiyPartner(myPartnerUtils::KALTURA_DELETE_ACCOUNT, $partner, $body_params);
if ($should_block_delete_partner) {
$partner->setStatus(Partner::PARTNER_STATUS_DELETED);
}
} elseif ($percent < 80 && ($partner->getUsageLimitWarning() || $partner->getEightyPercentWarning())) {
KalturaLog::debug("partner " . $partner->getId() . " OK");
// PARTNER OK
// resetting status and warnings should only be done manually
//$partner->setStatus(1);
$partner->setEightyPercentWarning(0);
$partner->setUsageLimitWarning(0);
}
$partner->save();
}