/** * Send the password notification email, if specified * @return void */ public function sendNotificationEmail() { if ($this->getProperty('passwordnotifymethod') == 'e') { $message = $this->modx->getOption('signupemail_message'); $placeholders = array('uid' => $this->object->get('username'), 'pwd' => $this->newPassword, 'ufn' => $this->profile->get('fullname'), 'sname' => $this->modx->getOption('site_name'), 'saddr' => $this->modx->getOption('emailsender'), 'semail' => $this->modx->getOption('emailsender'), 'surl' => $this->modx->getOption('url_scheme') . $this->modx->getOption('http_host') . $this->modx->getOption('manager_url')); foreach ($placeholders as $k => $v) { $message = str_replace('[[+' . $k . ']]', $v, $message); } $this->object->sendEmail($message); } }
/** * Used to send a notification email to a user for IPN notification. * * @param string $type Type of notification email to send. * @param \smSubscription $subscription The relevant Subscription object * @param \modUser $user The relevant User object. * @param \smProduct $product The relevant Product object * @param string|\smTransaction $transaction If a transaction is involved, the transaction object. * @return bool|string True if successful, an error message if not. */ public function sendNotificationEmail($type = '', smSubscription $subscription, modUser $user, smProduct $product, $transaction = '') { $chunk = ''; $subject = ''; $phs = array(); if (!$user instanceof modUser || !$subscription instanceof smSubscription || !$product instanceof smProduct) { $this->modx->log(MODX_LEVEL_ERROR, 'Error: invalid parameter(s) in SubscribeMe::sendNotificationEmail'); return 'Invalid parameter(s) in SubscribeMe::sendNotificationEmail'; } $up = $user->getOne('Profile'); $userarray = $user->toArray(); if ($up instanceof modUserProfile) { $userarray = array_merge($userarray, $up->toArray()); } $phs = array('user' => $userarray, 'subscription' => $subscription->toArray(), 'product' => $product->toArray(), 'settings' => $this->modx->config); if ($transaction instanceof smTransaction) { $phs['transaction'] = $transaction->toArray(); } switch ($type) { case 'recurring_payment_profile_cancel': $chunk = $this->modx->getOption('subscribeme.email.confirmcancel', null, 'smConfirmCancelEmail'); $subject = $this->modx->getOption('subscribeme.email.confirmcancel.subject', null, 'Your recurring payments profile for [[+product]] has been canceled.'); break; case 'recurring_payment_skipped': $chunk = $this->modx->getOption('subscribeme.email.notifyskippedpayment', null, 'smNotifySkippedPaymentEmail'); $subject = $this->modx->getOption('subscribeme.email.notifyskippedpayment.subject', null, 'A payment for your [[+product]] subscription has been skipped.'); break; case 'recurring_payment_expired': $chunk = $this->modx->getOption('subscribeme.email.paymentexpired', null, 'smPaymentExpiredEmail'); $subject = $this->modx->getOption('subscribeme.email.paymentexpired.subject', null, 'Your Recurring Payment for [[+product]] has expired.'); break; case 'recurring_payment_cancelledbyadmin': $chunk = $this->modx->getOption('subscribeme.email.confirmcancel.admin', null, 'smConfirmCancelAdminEmail'); $subject = $this->modx->getOption('subscribeme.email.confirmcancel.admin.subject', null, 'An administrator has cancelled your [[+product]] subscription.'); break; case 'subscription_expired': $chunk = $this->modx->getOption('subscribeme.email.subscriptionexpired', null, 'smSubscriptionExpiredEmail'); $subject = $this->modx->getOption('subscribeme.email.subscriptionexpired.subject', null, 'Your [[+product]] Subscription Expired.'); break; } $msg = $this->getChunk($chunk, $phs); $subject = str_replace(array('[[+product]]'), array($product->get('name')), $subject); if ($transaction instanceof smTransaction) { $subject = str_replace(array('[[+transid]]', '[[+transaction.method]]'), array($transaction->get('id'), $transaction->get('method')), $subject); } if ($user->sendEmail($msg, array('subject' => $subject)) !== true) { return 'Error sending email to user.'; } return true; }