/**
  * Send a lost password e-mail
  * @param object
  */
 protected function sendPasswordLink($objMember)
 {
     $objNotification = \NotificationCenter\Model\Notification::findByPk($this->nc_notification);
     if ($objNotification === null) {
         $this->log('The notification was not found ID ' . $this->nc_notification, __METHOD__, TL_ERROR);
         return;
     }
     $confirmationId = md5(uniqid(mt_rand(), true));
     // Store the confirmation ID
     $objMember = \MemberModel::findByPk($objMember->id);
     $objMember->activation = $confirmationId;
     $objMember->save();
     $arrTokens = array();
     // Add member tokens
     foreach ($objMember->row() as $k => $v) {
         $arrTokens['member_' . $k] = $v;
     }
     $arrTokens['recipient_email'] = $objMember->email;
     $arrTokens['domain'] = \Idna::decode(\Environment::get('host'));
     $arrTokens['link'] = \Idna::decode(\Environment::get('base')) . \Environment::get('request') . ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos(\Environment::get('request'), '?') !== false ? '&' : '?') . 'token=' . $confirmationId;
     $objNotification->send($arrTokens);
     $this->log('A new password has been requested for user ID ' . $objMember->id . ' (' . $objMember->email . ')', __METHOD__, TL_ACCESS);
     // Check whether there is a jumpTo page
     if (($objJumpTo = $this->objModel->getRelated('jumpTo')) !== null) {
         $this->jumpToOrReload($objJumpTo->row());
     }
     $this->reload();
 }
 public static function sendNotification($intSubmission, $intNotification, $arrTokens = array())
 {
     $arrTokens += static::generateTokens($intSubmission);
     if (($objNotification = Notification::findByPk($intNotification)) !== null) {
         $objNotification->submission = $intSubmission;
         $objNotification->send($arrTokens, $GLOBALS['TL_LANGUAGE']);
     }
 }
 public static function addSubscriptions(Order $objOrder, $arrTokens)
 {
     $strEmail = $objOrder->getBillingAddress()->email;
     $objAddress = $objOrder->getShippingAddress() ?: $objOrder->getBillingAddress();
     $arrItems = $objOrder->getItems();
     $objSession = \Session::getInstance();
     if (!($intModule = $objSession->get('isotopeCheckoutModuleIdSubscriptions'))) {
         return true;
     }
     $objSession->remove('isotopeCheckoutModuleIdSubscriptions');
     $objModule = \ModuleModel::findByPk($intModule);
     foreach ($arrItems as $item) {
         switch ($objModule->iso_direct_checkout_product_mode) {
             case 'product_type':
                 $objFieldpalette = FieldPaletteModel::findBy('iso_direct_checkout_product_type', Standard::findAvailableByIdOrAlias($item->product_id)->type);
                 break;
             default:
                 $objFieldpalette = FieldPaletteModel::findBy('iso_direct_checkout_product', $item->product_id);
                 break;
         }
         if ($objFieldpalette !== null && $objFieldpalette->iso_addSubscription) {
             if ($objFieldpalette->iso_subscriptionArchive && (!$objFieldpalette->iso_addSubscriptionCheckbox || \Input::post('subscribeToProduct_' . $item->product_id))) {
                 $objSubscription = Subscription::findOneBy(array('email=?', 'pid=?', 'activation!=?', 'disable=?'), array($strEmail, $objFieldpalette->iso_subscriptionArchive, '', 1));
                 if (!$objSubscription) {
                     $objSubscription = new Subscription();
                 }
                 if ($objFieldpalette->iso_addActivation) {
                     $strToken = md5(uniqid(mt_rand(), true));
                     $objSubscription->disable = true;
                     $objSubscription->activation = $strToken;
                     if (($objNotification = Notification::findByPk($objFieldpalette->iso_activationNotification)) !== null) {
                         if ($objFieldpalette->iso_activationJumpTo && ($objPageRedirect = \PageModel::findByPk($objFieldpalette->iso_activationJumpTo)) !== null) {
                             $arrTokens['link'] = \Environment::get('url') . '/' . \Controller::generateFrontendUrl($objPageRedirect->row()) . '?token=' . $strToken;
                         }
                         $objNotification->send($arrTokens, $GLOBALS['TL_LANGUAGE']);
                     }
                 }
                 $arrAddressFields = \Config::get('iso_addressFields');
                 if ($arrAddressFields === null) {
                     $arrAddressFields = serialize(array_keys(static::getIsotopeAddressFields()));
                 }
                 foreach (deserialize($arrAddressFields, true) as $strName) {
                     $objSubscription->{$strName} = $objAddress->{$strName};
                 }
                 $objSubscription->email = $strEmail;
                 $objSubscription->pid = $objFieldpalette->iso_subscriptionArchive;
                 $objSubscription->tstamp = $objSubscription->dateAdded = time();
                 $objSubscription->quantity = \Input::post('quantity');
                 $objSubscription->order_id = $objOrder->id;
                 $objSubscription->save();
             }
         }
     }
     return true;
 }
 /**
  * Check if the message can be member customizable
  * @category save_callback
  *
  * @param mixed          $varValue
  * @param \DataContainer $dc
  *
  * @return mixed
  * @throws \Exception
  */
 public function checkMessageMemberCustomizable($varValue, $dc)
 {
     /** @noinspection PhpUndefinedMethodInspection */
     $objNotification = Notification::findByPk($dc->activeRecord->pid);
     $strNotificationType = Notification::findGroupForType($objNotification->type);
     // Check the allowed tokens corresponding for this notification type
     foreach ($GLOBALS['NOTIFICATION_CENTER']['NOTIFICATION_TYPE'][$strNotificationType][$objNotification->type] as $field => $tokens) {
         // We have to check whether the member id will be passed to the message as token
         if (in_array('member_id', $tokens) || in_array('member_*', $tokens)) {
             return $varValue;
         }
     }
     throw new \Exception($GLOBALS['TL_LANG']['ERR']['messageNotMemberCustomizable']);
 }
Пример #5
0
 /**
  * Send the news message
  * @param integer
  * @return boolean
  */
 public function sendNewsMessage($intId)
 {
     $objNews = \NewsModel::findByPk($intId);
     if ($objNews === null) {
         return false;
     }
     $objArchive = $objNews->getRelated('pid');
     if ($objArchive === null || !$objArchive->newsletter || !$objArchive->newsletter_channel || !$objArchive->nc_notification) {
         return false;
     }
     $objNotification = \NotificationCenter\Model\Notification::findByPk($objArchive->nc_notification);
     if ($objNotification === null) {
         return false;
     }
     $objRecipients = \NewsletterRecipientsModel::findBy(array("pid=? AND active=1"), $objArchive->newsletter_channel);
     if ($objRecipients === null) {
         return false;
     }
     $arrTokens = array();
     // Generate news archive tokens
     foreach ($objArchive->row() as $k => $v) {
         $arrTokens['news_archive_' . $k] = \Haste\Util\Format::dcaValue('tl_news_archive', $k, $v);
     }
     // Generate news tokens
     foreach ($objNews->row() as $k => $v) {
         $arrTokens['news_' . $k] = \Haste\Util\Format::dcaValue('tl_news', $k, $v);
     }
     $arrTokens['news_text'] = '';
     $objElement = \ContentModel::findPublishedByPidAndTable($objNews->id, 'tl_news');
     // Generate news text
     if ($objElement !== null) {
         while ($objElement->next()) {
             $arrTokens['news_text'] .= $this->getContentElement($objElement->id);
         }
     }
     // Generate news URL
     $objPage = \PageModel::findWithDetails($objNews->getRelated('pid')->jumpTo);
     $arrTokens['news_url'] = ($objPage->rootUseSSL ? 'https://' : 'http://') . ($objPage->domain ?: \Environment::get('host')) . TL_PATH . '/' . $objPage->getFrontendUrl(($GLOBALS['TL_CONFIG']['useAutoItem'] && !$GLOBALS['TL_CONFIG']['disableAlias'] ? '/' : '/items/') . (!$GLOBALS['TL_CONFIG']['disableAlias'] && $objNews->alias != '' ? $objNews->alias : $objNews->id), $objPage->language);
     // Administrator e-mail
     $arrTokens['admin_email'] = $GLOBALS['TL_ADMIN_EMAIL'];
     while ($objRecipients->next()) {
         $arrTokens['recipient_email'] = $objRecipients->email;
         $objNotification->send($arrTokens);
     }
     // Set the newsletter flag
     $objNews->newsletter = 1;
     $objNews->save();
     return true;
 }
 /**
  * Send a lost password e-mail
  *
  * @param \MemberModel $objMember
  */
 protected function sendPasswordLink($objMember)
 {
     $objNotification = \NotificationCenter\Model\Notification::findByPk($this->nc_notification);
     if ($objNotification === null) {
         $this->log('The notification was not found ID ' . $this->nc_notification, __METHOD__, TL_ERROR);
         return;
     }
     $confirmationId = md5(uniqid(mt_rand(), true));
     // Store the confirmation ID
     $objMember = \MemberModel::findByPk($objMember->id);
     $objMember->activation = $confirmationId;
     $objMember->save();
     $arrTokens = array();
     // Add member tokens
     foreach ($objMember->row() as $k => $v) {
         if (\Validator::isBinaryUuid($v)) {
             $v = \StringUtil::binToUuid($v);
         }
         $arrTokens['member_' . $k] = specialchars($v);
     }
     // FIX: Add salutation token
     $arrTokens['salutation_user'] = NotificationCenterPlus::createSalutation($GLOBALS['TL_LANGUAGE'], $objMember);
     // ENDFIX
     $arrTokens['recipient_email'] = $objMember->email;
     $arrTokens['domain'] = \Idna::decode(\Environment::get('host'));
     $arrTokens['link'] = \Idna::decode(\Environment::get('base')) . \Environment::get('request') . ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos(\Environment::get('request'), '?') !== false ? '&' : '?') . 'token=' . $confirmationId;
     // FIX: Add custom change password jump to
     if (($objJumpTo = $this->objModel->getRelated('changePasswordJumpTo')) !== null) {
         $arrTokens['link'] = \Idna::decode(\Environment::get('base')) . \Controller::generateFrontendUrl($objJumpTo->row(), '?token=' . $confirmationId);
     }
     // ENDFIX
     $objNotification->send($arrTokens, $GLOBALS['TL_LANGUAGE']);
     $this->log('A new password has been requested for user ID ' . $objMember->id . ' (' . $objMember->email . ')', __METHOD__, TL_ACCESS);
     // Check whether there is a jumpTo page
     if (($objJumpTo = $this->objModel->getRelated('jumpTo')) !== null) {
         $this->jumpToOrReload($objJumpTo->row());
     }
     StatusMessage::addSuccess(sprintf($GLOBALS['TL_LANG']['notification_center_plus']['sendPasswordLink']['messageSuccess'], $arrTokens['recipient_email']), $this->objModel->id);
     $this->reload();
 }
 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var Message|\Model\Collection $objMessages */
     /** @noinspection PhpUndefinedMethodInspection */
     $objMessages = Message::findBy(array('pid IN (' . implode(',', $this->nc_member_customizable_notifications) . ') AND member_customizable<>\'\''), array());
     $arrOptions = array();
     $arrSelected = array();
     while ($objMessages->next()) {
         if (MemberMessages::memberHasSelected(\FrontendUser::getInstance()->id, $objMessages->id)) {
             $arrSelected[$objMessages->pid][] = $objMessages->id;
         }
         // Fetch tokens for parsing the option labels
         $objNotification = $objMessages->getRelated('pid');
         $objGateway = $objMessages->getRelated('gateway');
         $arrTokens = array_merge(array_combine(array_map(function ($key) {
             return 'message_' . $key;
         }, array_keys($objMessages->row())), $objMessages->row()), array_combine(array_map(function ($key) {
             return 'notification_' . $key;
         }, array_keys($objNotification->row())), $objNotification->row()), array_combine(array_map(function ($key) {
             return 'gateway_' . $key;
         }, array_keys($objGateway->row())), $objGateway->row()));
         $arrOptions[$objMessages->pid][$objMessages->id] = \StringUtil::parseSimpleTokens($this->nc_member_customizable_label ?: '##message_title## (##gateway_title##)', $arrTokens);
     }
     $objForm = new Form('tl_select_notifications', 'POST', function ($objHaste) {
         /** @noinspection PhpUndefinedMethodInspection */
         return \Input::post('FORM_SUBMIT') === $objHaste->getFormId();
     });
     foreach ($arrOptions as $k => $options) {
         /** @noinspection PhpUndefinedMethodInspection */
         $objForm->addFormField('notification_' . $k, array('label' => Notification::findByPk($objMessages->pid)->title, 'inputType' => $this->nc_member_customizable_inputType, 'options' => $options, 'eval' => array('mandatory' => $this->nc_member_customizable_mandatory), 'value' => !empty($arrSelected[$k]) ? $arrSelected[$k] : array()));
         // Add a validator
         // We check whether it is possible to send the message to the recipient by means of the gateway
         // E.g. a sms message requires a phone number set by the member which is not default
         $objForm->addValidator('notification_' . $k, function ($varValue, $objWidget, $objForm) use($k, $arrOptions) {
             if (empty($varValue)) {
                 return $varValue;
             }
             foreach ($varValue as $msg) {
                 /** @noinspection PhpUndefinedMethodInspection */
                 /** @var Message|\Model $objMessage */
                 $objMessage = Message::findByPk($msg);
                 /** @noinspection PhpUndefinedMethodInspection */
                 /** @var GatewayInterface|MessageDraftCheckSendInterface $objGateway */
                 $objGateway = $objMessage->getRelated('gateway')->getGateway();
                 if (!$objGateway instanceof MessageDraftCheckSendInterface) {
                     continue;
                 }
                 // Throw the error message as exception if the method has not yet
                 if (!$objGateway->canSendDraft($objMessage)) {
                     throw new \Exception(sprintf($GLOBALS['TL_LANG']['ERR']['messageNotSelectable'], $arrOptions[$k][$msg]));
                 }
             }
             return $varValue;
         });
     }
     $objForm->addSubmitFormField('submit', $GLOBALS['TL_LANG']['MSC']['saveSettings']);
     // Process form submit
     if ($objForm->validate()) {
         $arrData = $objForm->fetchAll();
         foreach ($arrData as $field => $notification) {
             if (strpos($field, 'notification_') !== 0) {
                 continue;
             }
             list(, $notificationId) = trimsplit('_', $field);
             // Delete
             foreach (array_diff((array) $arrSelected[$notificationId], (array) $notification) as $msg) {
                 /** @noinspection PhpUndefinedMethodInspection */
                 MemberMessages::findByMemberAndMessage(\FrontendUser::getInstance()->id, $msg)->delete();
             }
             // Create
             foreach (array_diff((array) $notification, (array) $arrSelected[$notificationId]) as $msg) {
                 /** @var MemberMessages|\Model $objMemberMessage */
                 $objMemberMessage = new MemberMessages();
                 $objMemberMessage->member_id = \FrontendUser::getInstance()->id;
                 $objMemberMessage->message_id = $msg;
                 $objMemberMessage->save();
             }
         }
     }
     $this->Template->form = $objForm->generate();
 }
 /**
  * Send the personal data change e-mail
  * @param object
  * @param array
  * @param object
  */
 public function sendPersonalDataEmail($objUser, $arrData, $objModule)
 {
     if (!$objModule->nc_notification) {
         return;
     }
     $arrTokens = array();
     $arrTokens['admin_email'] = $GLOBALS['TL_ADMIN_EMAIL'];
     $arrTokens['domain'] = \Environment::get('host');
     // Support newsletters
     if (in_array('newsletter', $this->Config->getActiveModules())) {
         if (!is_array($arrData['newsletter'])) {
             if ($arrData['newsletter'] != '') {
                 $objChannels = \Database::getInstance()->execute("SELECT title FROM tl_newsletter_channel WHERE id IN(" . implode(',', array_map('intval', (array) $arrData['newsletter'])) . ")");
                 $arrTokens['member_newsletter'] = implode("\n", $objChannels->fetchEach('title'));
             } else {
                 $arrTokens['member_newsletter'] = '';
             }
         }
     }
     // Translate/format old values
     foreach ($_SESSION['PERSONAL_DATA'] as $strFieldName => $strFieldValue) {
         $arrTokens['member_old_' . $strFieldName] = \Haste\Util\Format::dcaValue('tl_member', $strFieldName, $strFieldValue);
     }
     // Translate/format new values
     foreach ($arrData as $strFieldName => $strFieldValue) {
         $arrTokens['member_' . $strFieldName] = \Haste\Util\Format::dcaValue('tl_member', $strFieldName, $strFieldValue);
     }
     $objNotification = \NotificationCenter\Model\Notification::findByPk($objModule->nc_notification);
     if ($objNotification !== null) {
         $objNotification->send($arrTokens);
     }
 }
Пример #9
0
 /**
  * Retrieve the array of notification data for parsing simple tokens
  *
  * @param int $intNotification
  *
  * @return array
  */
 public function getNotificationTokens($intNotification)
 {
     /** @type \Isotope\Model\Config $objConfig */
     $objConfig = $this->getRelated('config_id');
     $arrTokens = deserialize($this->email_data, true);
     $arrTokens['uniqid'] = $this->uniqid;
     $arrTokens['order_status_id'] = $this->order_status;
     $arrTokens['order_status'] = $this->getStatusLabel();
     $arrTokens['recipient_email'] = $this->getEmailRecipient();
     $arrTokens['order_id'] = $this->id;
     $arrTokens['order_items'] = $this->sumItemsQuantity();
     $arrTokens['order_products'] = $this->countItems();
     $arrTokens['order_subtotal'] = Isotope::formatPriceWithCurrency($this->getSubtotal(), false);
     $arrTokens['order_total'] = Isotope::formatPriceWithCurrency($this->getTotal(), false);
     $arrTokens['document_number'] = $this->document_number;
     $arrTokens['cart_html'] = '';
     $arrTokens['cart_text'] = '';
     $arrTokens['document'] = '';
     // Add all the collection fields
     foreach ($this->row() as $k => $v) {
         $arrTokens['collection_' . $k] = $v;
     }
     // Add billing/customer address fields
     if (($objAddress = $this->getBillingAddress()) !== null) {
         foreach ($objAddress->row() as $k => $v) {
             $arrTokens['billing_address_' . $k] = Format::dcaValue($objAddress->getTable(), $k, $v);
             // @deprecated (use ##billing_address_*##)
             $arrTokens['billing_' . $k] = $arrTokens['billing_address_' . $k];
         }
         $arrTokens['billing_address'] = $objAddress->generate($objConfig->getBillingFieldsConfig());
         // @deprecated (use ##billing_address##)
         $arrTokens['billing_address_text'] = $arrTokens['billing_address'];
     }
     // Add shipping address fields
     if (($objAddress = $this->getShippingAddress()) !== null) {
         foreach ($objAddress->row() as $k => $v) {
             $arrTokens['shipping_address_' . $k] = Format::dcaValue($objAddress->getTable(), $k, $v);
             // @deprecated (use ##billing_address_*##)
             $arrTokens['shipping_' . $k] = $arrTokens['shipping_address_' . $k];
         }
         $arrTokens['shipping_address'] = $objAddress->generate($objConfig->getShippingFieldsConfig());
         // Shipping address equals billing address
         // @deprecated (use ##shipping_address##)
         if ($objAddress->id == $this->getBillingAddress()->id) {
             $arrTokens['shipping_address_text'] = $this->requiresPayment() ? $GLOBALS['TL_LANG']['MSC']['useBillingAddress'] : $GLOBALS['TL_LANG']['MSC']['useCustomerAddress'];
         } else {
             $arrTokens['shipping_address_text'] = $arrTokens['shipping_address'];
         }
     }
     // Add payment method info
     if ($this->hasPayment() && ($objPayment = $this->getPaymentMethod()) !== null) {
         $arrTokens['payment_id'] = $objPayment->id;
         $arrTokens['payment_label'] = $objPayment->getLabel();
         $arrTokens['payment_note'] = $objPayment->note;
     }
     // Add shipping method info
     if ($this->hasShipping() && ($objShipping = $this->getShippingMethod()) !== null) {
         $arrTokens['shipping_id'] = $objShipping->id;
         $arrTokens['shipping_label'] = $objShipping->getLabel();
         $arrTokens['shipping_note'] = $objShipping->note;
     }
     // Add config fields
     if ($this->getRelated('config_id') !== null) {
         foreach ($this->getRelated('config_id')->row() as $k => $v) {
             $arrTokens['config_' . $k] = Format::dcaValue($this->getRelated('config_id')->getTable(), $k, $v);
         }
     }
     // Add member fields
     if ($this->member > 0 && $this->getRelated('member') !== null) {
         foreach ($this->getRelated('member')->row() as $k => $v) {
             $arrTokens['member_' . $k] = Format::dcaValue($this->getRelated('member')->getTable(), $k, $v);
         }
     }
     if ($intNotification > 0 && ($objNotification = Notification::findByPk($intNotification)) !== null) {
         $objTemplate = new \Isotope\Template($objNotification->iso_collectionTpl);
         $objTemplate->isNotification = true;
         $this->addToTemplate($objTemplate, array('gallery' => $objNotification->iso_gallery, 'sorting' => $this->getItemsSortingCallable($objNotification->iso_orderCollectionBy)));
         $arrTokens['cart_html'] = Haste::getInstance()->call('replaceInsertTags', array($objTemplate->parse(), false));
         $objTemplate->textOnly = true;
         $arrTokens['cart_text'] = strip_tags(Haste::getInstance()->call('replaceInsertTags', array($objTemplate->parse(), true)));
         // Generate and "attach" document
         /** @var \Isotope\Interfaces\IsotopeDocument $objDocument */
         if ($objNotification->iso_document > 0 && ($objDocument = Document::findByPk($objNotification->iso_document)) !== null) {
             $strFilePath = $objDocument->outputToFile($this, TL_ROOT . '/system/tmp');
             $arrTokens['document'] = str_replace(TL_ROOT . '/', '', $strFilePath);
         }
     }
     // !HOOK: add custom email tokens
     if (isset($GLOBALS['ISO_HOOKS']['getOrderNotificationTokens']) && is_array($GLOBALS['ISO_HOOKS']['getOrderNotificationTokens'])) {
         foreach ($GLOBALS['ISO_HOOKS']['getOrderNotificationTokens'] as $callback) {
             $objCallback = \System::importStatic($callback[0]);
             $arrTokens = $objCallback->{$callback}[1]($this, $arrTokens);
         }
     }
     return $arrTokens;
 }
 /**
  * @category ISO_HOOKS: postCheckout
  *
  * @param ProductCollection\Order $order
  * @param array                   $tokens
  *
  */
 public function updateStockPostCheckout(ProductCollection\Order $order, array $tokens)
 {
     foreach ($order->getItems() as $item) {
         /** @var Product|\Model $product */
         $product = $item->getProduct();
         $productType = $product->getRelated('type');
         if ($productType->stockmanagement_active) {
             // Book stock change
             /** @var Stock|\Model $stockChange */
             $stockChange = new Stock();
             $stockChange->tstamp = time();
             $stockChange->pid = $product->id;
             $stockChange->product_collection_id = $order->id;
             $stockChange->quantity = -1 * (int) $item->quantity;
             $stockChange->source = Stock::STOCKMANAGEMENT_SOURCE_ORDER;
             $stockChange->save();
             // Fetch current stock
             $stock = Stock::getStockForProduct($product->id);
             // Disable product if necessary
             if ($productType->stockmanagement_disableProduct && false !== $stock && $stock < 1) {
                 $product->published = '';
                 $product->save();
             }
             // Send stock change notifications
             if ($productType->stockmanagement_notification) {
                 $notifications = deserialize($productType->stockmanagement_notifications);
                 foreach ($notifications as $notification) {
                     if ($stock <= $notification['threshold']) {
                         /** @noinspection PhpUndefinedMethodInspection */
                         /** @var Notification $notificationCenter */
                         $notificationCenter = Notification::findByPk($notification['nc_id']);
                         if (null !== $notificationCenter) {
                             $notificationCenter->send(self::createStockChangeNotifictionTokens($product, $order));
                         }
                         // Do not send multiple notifications
                         break;
                     }
                 }
             }
         }
     }
 }
 public static function sendNotification($intId, $arrTokens)
 {
     if (($objNotification = Notification::findByPk($intId)) !== null) {
         $objNotification->send($arrTokens, $GLOBALS['TL_LANGUAGE']);
     }
 }
 public static function sendOrderNotification($objOrder, $arrTokens)
 {
     $arrItems = $objOrder->getItems();
     // only send one one notification per product type and order
     $arrProductTypes = array();
     foreach ($arrItems as $objItem) {
         $arrProductTypes[] = $objItem->getProduct()->type;
     }
     foreach (array_unique($arrProductTypes) as $intProductType) {
         if (($objProductType = ProductType::findByPk($intProductType)) !== null) {
             if ($objProductType->sendOrderNotification && ($objNotification = Notification::findByPk($objProductType->orderNotification)) !== null) {
                 if ($objProductType->removeOtherProducts) {
                     $objNotification->send(static::getCleanTokens($intProductType, $objOrder, $objNotification, $arrTokens), $GLOBALS['TL_LANGUAGE']);
                 } else {
                     $objNotification->send($arrTokens, $GLOBALS['TL_LANGUAGE']);
                 }
             }
         }
     }
 }
Пример #13
0
 /**
  * Send the notification
  */
 public function sendNotification()
 {
     if (!\Input::get('master') || !\Leads\NotificationCenterIntegration::available(true)) {
         \Controller::redirect('contao/main.php?act=error');
     }
     // No need to check for null as NotificationCenterIntegration::available(true) already does
     $notificationsCollection = \NotificationCenter\Model\Notification::findBy('type', 'core_form');
     $notifications = [];
     // Generate the notifications
     foreach ($notificationsCollection as $notification) {
         $notifications[$notification->id] = $notification->title;
     }
     // Process the form
     if ('tl_leads_notification' === \Input::post('FORM_SUBMIT')) {
         /**
          * @var \FormModel                             $form
          * @var \NotificationCenter\Model\Notification $notification
          */
         if (!isset($notifications[\Input::post('notification')]) || !is_array(\Input::post('IDS')) || ($form = \FormModel::findByPk(\Input::get('master'))) === null || null === ($notification = \NotificationCenter\Model\Notification::findByPk(\Input::post('notification')))) {
             \Controller::reload();
         }
         if (\Input::get('id')) {
             $ids = [(int) \Input::get('id')];
         } else {
             $session = \Session::getInstance()->getData();
             $ids = array_map('intval', $session['CURRENT']['IDS']);
         }
         foreach ($ids as $id) {
             if (\Leads\NotificationCenterIntegration::send($id, $form, $notification)) {
                 \Message::addConfirmation(sprintf($GLOBALS['TL_LANG']['tl_lead']['notification_confirm'], $id));
             }
         }
         \Controller::redirect($this->getReferer());
     }
     return \Leads\NotificationCenterIntegration::generateForm($notifications, [\Input::get('id')]);
 }
Пример #14
0
 /**
  * Send a notification when address has been changed
  *
  * @param Address $objAddress
  * @param array   $arrOldAddress
  * @param \User   $objMember
  * @param Config  $objConfig
  */
 protected function triggerNotificationCenter(Address $objAddress, array $arrOldAddress, \User $objMember, Config $objConfig)
 {
     if (!$this->nc_notification) {
         return;
     }
     /** @type Notification $objNotification */
     $objNotification = Notification::findByPk($this->nc_notification);
     if (null === $objNotification) {
         return;
     }
     $arrTokens = array();
     $arrTokens['admin_email'] = $GLOBALS['TL_ADMIN_EMAIL'];
     $arrTokens['domain'] = \Environment::get('host');
     $arrTokens['link'] = \Environment::get('base') . \Environment::get('request');
     foreach ($objAddress->row() as $k => $v) {
         $arrTokens['address_' . $k] = $v;
     }
     foreach ($arrOldAddress as $k => $v) {
         $arrTokens['address_old_' . $k] = $v;
     }
     foreach ($objMember->getData() as $k => $v) {
         $arrTokens['member_' . $k] = $v;
     }
     foreach ($objConfig->row() as $k => $v) {
         $arrTokens['config_' . $k] = $v;
     }
     $objNotification->send($arrTokens);
 }