public static function getTimeStamp($ved2f216e8eb7276d3e828504ebdf5437) { return toTimeStamp($ved2f216e8eb7276d3e828504ebdf5437); }
protected function sendNotification() { $daysLeft = regedit::getInstance()->getVal("//modules/banners/days-before-notification"); $daysLeft = $daysLeft * 24 * 3600; $viewsLeft = regedit::getInstance()->getVal("//modules/banners/clicks-before-notification"); $items = array(); $sel = new selector('objects'); $sel->types('object-type')->name('banners', 'banner'); foreach ($sel->result() as $banner) { $tillDate = toTimeStamp($banner->getValue('show_till_date')); $viewsCount = $banner->getValue('views_count'); $maxViews = $banner->getValue('max_views'); $days = false; $views = false; if ((int) $tillDate && time() + $daysLeft >= $tillDate) { $days = true; } if ((int) $maxViews && $viewsCount + $viewsLeft >= $maxViews) { $views = true; } if ($days || $views) { $bannerId = $banner->id; $bannerName = $banner->getName(); $domain = domainsCollection::getInstance()->getDefaultDomain(); $link = "http://" . $domain->getHost() . '/admin/banners/edit/' . $bannerId; list($templateLine) = def_module::loadTemplatesForMail("mail/banner_notification", "item"); $itemArr['link'] = $link; $itemArr['bannerName'] = $bannerName; if ($days) { $itemArr['tillDate'] = ' - срок показа истекает ' . $banner->getValue('show_till_date')->getFormattedDate() . '.'; } elseif ($views) { $itemArr['tillDate'] = ' - оставшееся количество показов: ' . ($maxViews - $viewsCount) . '.'; } else { $itemArr['tillDate'] = ''; } $items[] = def_module::parseTemplateForMail($templateLine, $itemArr, false, $bannerId); } } if (count($items)) { $blockArr = array(); list($subject, $template) = def_module::loadTemplatesForMail("mail/banner_notification", "subject", "body"); $mailMessage = new umiMail(); $from = regedit::getInstance()->getVal("//settings/email_from"); $mailMessage->setFrom($from); $emailTo = regedit::getInstance()->getVal("//settings/admin_email"); $mailMessage->addRecipient($emailTo); $mailMessage->setPriorityLevel("high"); $subject = def_module::parseTemplateForMail($subject, $blockArr); $mailMessage->setSubject($subject); $blockArr['header'] = $subject; $blockArr['+items'] = $items; $content = def_module::parseTemplateForMail($template, $blockArr); $mailMessage->setContent($content); $mailMessage->commit(); $mailMessage->send(); regedit::getInstance()->setVal("//modules/banners/last-check-date", time()); } }