Пример #1
0
 public function email($addressee, $address, $subject, array $templates = array())
 {
     global $is_IIS;
     shopp_debug("ShoppPurchase::email(): {$addressee},{$address},{$subject}," . _object_r($templates));
     // Build the e-mail message data
     $email['from'] = Shopp::email_from(shopp_setting('merchant_email'), shopp_setting('business_name'));
     if ($is_IIS) {
         $email['to'] = Shopp::email_to($address);
     } else {
         $email['to'] = Shopp::email_to($address, $addressee);
     }
     $email['subject'] = $subject;
     $email['receipt'] = $this->receipt();
     $email['url'] = get_bloginfo('url');
     $email['sitename'] = get_bloginfo('name');
     $email['orderid'] = $this->id;
     $email = apply_filters('shopp_email_receipt_data', $email);
     $email = apply_filters('shopp_purchase_email_message', $email);
     $this->message = array_merge($this->message, $email);
     // Load and process the template file
     $defaults = array('email.php', 'order.php', 'order.html');
     $emails = array_merge((array) $templates, $defaults);
     $template = Shopp::locate_template($emails);
     if (!file_exists($template)) {
         shopp_add_error(Shopp::__('A purchase notification could not be sent because the template for it does not exist.'), SHOPP_ADMIN_ERR);
         return false;
     }
     // Send the email
     if (Shopp::email($template, $this->message)) {
         shopp_debug('A purchase notification was sent to: ' . $this->message['to']);
         return true;
     }
     shopp_debug('A purchase notification FAILED to be sent to: ' . $this->message['to']);
     return false;
 }
Пример #2
0
 /**
  * Send new customer notification emails
  *
  * @author Jonathan Davis
  * @since 1.2
  *
  * @return void
  **/
 public function notification()
 {
     // The blogname option is escaped with esc_html on the way into the database in sanitize_option
     // we want to reverse this for the plain text arena of emails.
     $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
     $business = shopp_setting('business_name');
     $merchant = shopp_setting('merchant_email');
     $_ = array();
     $_[] = 'From: ' . Shopp::email_from($merchant, $business);
     $_[] = 'To: ' . Shopp::email_to($merchant);
     $_[] = 'Subject: ' . Shopp::__('[%s] New Customer Registration', $blogname);
     $_[] = '';
     $_[] = Shopp::__('New customer registration on your "%s" store:', $blogname);
     $_[] = Shopp::__('E-mail: %s', stripslashes($this->email));
     $_ = apply_filters('shopp_merchant_new_customer_notification', $_);
     if (!Shopp::email(join("\n", $_))) {
         shopp_add_error('The new account notification e-mail could not be sent.', SHOPP_ADMIN_ERR);
     } else {
         shopp_debug('A new account notification e-mail was sent to the merchant.');
     }
     if (empty($this->password)) {
         return;
     }
     $_ = array();
     $_[] = 'From: ' . Shopp::email_from($merchant, $business);
     $_[] = 'To: ' . $this->email;
     $_[] = 'Subject: ' . Shopp::__('[%s] New Customer Registration', $blogname);
     $_[] = '';
     $_[] = Shopp::__('New customer registration on your "%s" store:', $blogname);
     $_[] = Shopp::__('E-mail: %s', stripslashes($this->email));
     $_[] = Shopp::__('Password: %s', $this->password);
     $_[] = '';
     $_[] = Shopp::url(false, 'account', ShoppOrder()->security());
     $_ = apply_filters('shopp_new_customer_notification', $_);
     if (!Shopp::email(join("\n", $_))) {
         shopp_add_error('The customer's account notification e-mail could not be sent.', SHOPP_ADMIN_ERR);
     } else {
         shopp_debug('A new account notification e-mail was sent to the customer.');
     }
 }
Пример #3
0
 static function resetpassword($activation)
 {
     if ('none' == shopp_setting('account_system')) {
         return;
     }
     $user_data = false;
     $activation = preg_replace('/[^a-z0-9]/i', '', $activation);
     $errors = array();
     if (empty($activation) || !is_string($activation)) {
         $errors[] = new ShoppError(Shopp::__('Invalid key'));
     }
     $RecoveryCustomer = new ShoppCustomer($activation, 'activation');
     if (empty($RecoveryCustomer->id)) {
         $errors[] = new ShoppError(Shopp::__('Invalid key'));
     }
     if (!empty($errors)) {
         return false;
     }
     // Generate a new random password
     $password = wp_generate_password();
     do_action_ref_array('password_reset', array($RecoveryCustomer, $password));
     $RecoveryCustomer->password = wp_hash_password($password);
     if ('wordpress' == shopp_setting('account_system')) {
         $user_data = get_userdata($RecoveryCustomer->wpuser);
         wp_set_password($password, $user_data->ID);
     }
     $RecoveryCustomer->activation = '';
     $RecoveryCustomer->save();
     $subject = apply_filters('shopp_reset_password_subject', Shopp::__('[%s] New Password', get_option('blogname')));
     $_ = array();
     $_[] = 'From: ' . Shopp::email_from(shopp_setting('merchant_email'), shopp_setting('business_name'));
     $_[] = 'To: ' . $RecoveryCustomer->email;
     $_[] = 'Subject: ' . $subject;
     $_[] = 'Content-type: text/html';
     $_[] = '';
     $_[] = '<p>' . Shopp::__('Your new password for %s:', get_bloginfo('url')) . '</p>';
     $_[] = '';
     $_[] = '<ul>';
     if ($user_data) {
         $_[] = '<li>' . Shopp::__('Login name: %s', $user_data->user_login) . '</li>';
     }
     $_[] = '<li>' . Shopp::__('Password: %s', $password) . '</li>';
     $_[] = '</ul>';
     $_[] = '';
     $_[] = '<p>' . Shopp::__('Click here to login: %s', Shopp::url(false, 'account')) . '</p>';
     $message = apply_filters('shopp_reset_password_message', $_);
     if (!Shopp::email(join("\n", $message))) {
         shopp_add_error(Shopp::__('The e-mail could not be sent.'));
         Shopp::redirect(add_query_arg('acct', 'recover', Shopp::url(false, 'account')));
     } else {
         shopp_add_error(Shopp::__('Check your email address for your new password.'));
     }
     unset($_GET['acct']);
 }
Пример #4
0
 /**
  * Resets a customer/user password with a valid activation key
  *
  * @since 1.0
  *
  * @param string $activation The activation key
  * @return void
  **/
 static function resetpassword($activation)
 {
     if ('none' == shopp_setting('account_system') || ShoppCustomer()->loggedin()) {
         return;
     }
     $user_data = false;
     $activation = preg_replace('/[^a-z0-9]/i', '', $activation);
     $errors = array();
     if (empty($activation) || !is_string($activation)) {
         $errors[] = shopp_add_error(Shopp::__("Invalid password reset key. Try copy/pasting the url in password reset email into your web browser's address bar."));
     } else {
         $RecoveryCustomer = new ShoppCustomer($activation, 'activation');
         if (empty($RecoveryCustomer->id)) {
             $errors[] = shopp_add_error(Shopp::__("Invalid password reset key. Try copy/pasting the url in password reset email into your web browser's address bar."));
         }
     }
     if (!empty($errors)) {
         return false;
     }
     // Generate a new random password
     $password = wp_generate_password(12, false);
     do_action_ref_array('password_reset', array($RecoveryCustomer, $password));
     $RecoveryCustomer->password = wp_hash_password($password);
     if ('wordpress' == shopp_setting('account_system')) {
         $user_data = get_userdata($RecoveryCustomer->wpuser);
         wp_set_password($password, $user_data->ID);
     }
     $RecoveryCustomer->activation = '';
     $RecoveryCustomer->save();
     $subject = apply_filters('shopp_reset_password_subject', Shopp::__('[%s] New Password', get_option('blogname')));
     $_ = array();
     $_[] = 'From: ' . Shopp::email_from(shopp_setting('merchant_email'), shopp_setting('business_name'));
     $_[] = 'To: ' . $RecoveryCustomer->email;
     $_[] = 'Subject: ' . $subject;
     $_[] = 'Content-type: text/html';
     $_[] = '';
     $_[] = '<p>' . Shopp::__('Your new password for %s:', get_bloginfo('url')) . '</p>';
     $_[] = '';
     $_[] = '<ul>';
     if (apply_filters('shopp_reset_password_wpuser', true) && !empty($user_data->user_login)) {
         $_[] = '<li>' . Shopp::__('Login: %s', $user_data->user_login) . '</li>';
     } elseif (!empty($RecoveryCustomer->email)) {
         $_[] = '<li>' . Shopp::__('Login: %s', $RecoveryCustomer->email) . '</li>';
     }
     $_[] = '<li>' . Shopp::__('Password: %s', $password) . '</li>';
     $_[] = '</ul>';
     $_[] = '';
     $_[] = '<p>' . Shopp::__('Click here to login: %s', Shopp::url(false, 'account')) . '</p>';
     $message = apply_filters('shopp_reset_password_message', $_);
     if (!Shopp::email(join("\n", $message))) {
         shopp_add_notice(Shopp::__('Your password was reset to: ' . $password));
     } else {
         shopp_add_notice(Shopp::__('Your new password has been emailed to you for your records. Your password was reset to: ' . $password));
     }
     unset($_GET['acct']);
     // Auto-login
     $RecoveryCustomer->login();
     // Login the customer
     if (!empty($user_data)) {
         // Log the WordPress user in
         ShoppLogin::wpuser($user_data);
     }
     // Show notice after login in case of failures during login
     shopp_add_notice(Shopp::__('You are now logged into your account.'));
     if (apply_filters('shopp_reset_password_redirect', true)) {
         shopp_add_notice(Shopp::__('If you wish, please use the form below to change your password to one of your choosing.'));
         Shopp::redirect(add_query_arg('profile', '', Shopp::url(false, 'account')));
     }
 }