Пример #1
0
/**
 * @since 3.4
 */
function awpcp_send_listing_was_flagged_notification($listing)
{
    if (!get_awpcp_option('send-listing-flagged-notification-to-administrators')) {
        return false;
    }
    $query_args = array('page' => 'awpcp-listings', 'filterby' => 'flagged', 'filter' => 1);
    $flagged_listings_url = add_query_arg($query_args, awpcp_get_admin_panel_url());
    $params = array('site_name' => get_bloginfo('name'), 'flagged_listings_url' => $flagged_listings_url);
    $template = AWPCP_DIR . '/templates/email/listing-was-flagged.plain.tpl.php';
    $mail = new AWPCP_Email();
    $mail->to = awpcp_admin_email_to();
    $mail->subject = str_replace('<listing-title>', $listing->get_title(), __('Listing <listing-title> was flagged', 'AWPCP'));
    $mail->prepare($template, $params);
    return $mail->send();
}
Пример #2
0
/**
 * Check if any Ad is about to expire and send an email to the poster.
 *
 * This functions runs daily.
 */
function awpcp_ad_renewal_email()
{
    global $wpdb;
    if (!(get_awpcp_option('sent-ad-renew-email') == 1)) {
        return;
    }
    $notification = awpcp_listing_is_about_to_expire_notification();
    $admin_sender_email = awpcp_admin_email_from();
    foreach (awpcp_get_listings_about_to_expire() as $listing) {
        // When the user clicks the renew ad link, AWPCP uses
        // the is_about_to_expire() method to decide if the Ad
        // can be renewed. We double check here to make
        // sure users can use the link in the email immediately.
        if (!$listing->is_about_to_expire()) {
            continue;
        }
        $email = new AWPCP_Email();
        $email->from = $admin_sender_email;
        $email->to = $listing->ad_contact_email;
        $email->subject = $notification->render_subject($listing);
        $email->body = $notification->render_body($listing);
        if ($email->send()) {
            $listing->renew_email_sent = true;
            $listing->save();
        }
    }
}
Пример #3
0
 public function send_access_key()
 {
     global $nameofsite;
     $ad = AWPCP_Ad::find_by_id($this->id);
     $recipient = "{$ad->ad_contact_name} <{$ad->ad_contact_email}>";
     $template = AWPCP_DIR . '/frontend/templates/email-send-ad-access-key.tpl.php';
     $message = new AWPCP_Email();
     $message->to[] = $recipient;
     $message->subject = sprintf('Access Key for "%s"', $ad->get_title());
     $message->prepare($template, array('ad' => $ad, 'nameofsite' => $nameofsite));
     if ($message->send()) {
         awpcp_flash(sprintf(__('The access key was sent to %s.', 'AWPCP'), esc_html($recipient)));
     } else {
         awpcp_flash(sprintf(__('There was an error trying to send the email to %s.', 'AWPCP'), esc_html($recipient)));
     }
     return $this->redirect('index');
 }
Пример #4
0
/**
 * @since 2.1.4
 */
function awpcp_ad_posted_email($ad, $transaction = null, $message = '', $notify_admin = true)
{
    $result = false;
    // user email
    $user_message = awpcp_ad_posted_user_email($ad, $transaction, $message);
    if (get_awpcp_option('send-user-ad-posted-notification', true)) {
        $result = $user_message->send();
    }
    // admin email
    if ($notify_admin && get_awpcp_option('notifyofadposted')) {
        // grab the body to be included in the email sent to the admin
        $content = $user_message->body;
        $admin_message = new AWPCP_Email();
        $admin_message->to[] = awpcp_admin_email_to();
        $admin_message->subject = __('New classified listing created', 'AWPCP');
        $params = array('page' => 'awpcp-listings', 'action' => 'view', 'id' => $ad->ad_id);
        $url = add_query_arg(urlencode_deep($params), admin_url('admin.php'));
        $template = AWPCP_DIR . '/frontend/templates/email-place-ad-success-admin.tpl.php';
        $admin_message->prepare($template, compact('content', 'url'));
        $admin_message->send();
    }
    return $result;
}
Пример #5
0
 /**
  * @since 3.0.2
  */
 public function send_verification_email($ad)
 {
     $mail = new AWPCP_Email();
     $mail->to[] = awpcp_format_email_address($ad->ad_contact_email, $ad->ad_contact_name);
     $mail->subject = sprintf(__('Verify the email address used for Ad "%s"', 'AWPCP'), $ad->get_title());
     $verification_link = awpcp_get_email_verification_url($ad->ad_id);
     $template = AWPCP_DIR . '/frontend/templates/email-ad-awaiting-verification.tpl.php';
     $mail->prepare($template, array('contact_name' => $ad->ad_contact_name, 'ad_title' => $ad->get_title(), 'verification_link' => $verification_link));
     if ($mail->send()) {
         $emails_sent = intval(awpcp_get_ad_meta($ad->ad_id, 'verification_emails_sent', true));
         awpcp_update_ad_meta($ad->ad_id, 'verification_email_sent_at', awpcp_datetime());
         awpcp_update_ad_meta($ad->ad_id, 'verification_emails_sent', $emails_sent + 1);
     }
 }
Пример #6
0
 public function send_access_keys($ads, &$errors = array())
 {
     $ad = reset($ads);
     $recipient = "{$ad->ad_contact_name} <{$ad->ad_contact_email}>";
     $template = AWPCP_DIR . '/frontend/templates/email-send-all-ad-access-keys.tpl.php';
     $message = new AWPCP_Email();
     $message->to[] = $recipient;
     $message->subject = get_awpcp_option('resendakeyformsubjectline');
     $message->prepare($template, array('ads' => $ads, 'introduction' => get_awpcp_option('resendakeyformbodymessage')));
     if ($message->send()) {
         $this->messages[] = sprintf(__('The access keys were sent to %s.', 'AWPCP'), esc_html($recipient));
         return true;
     } else {
         $errors[] = sprintf(__('There was an error trying to send the email to %s.', 'AWPCP'), esc_html($recipient));
         return false;
     }
 }
Пример #7
0
/**
 * email the administrator and the user to notify that the payment process was failed
 * @since  2.1.4
 */
function awpcp_payment_failed_email($transaction, $message = '')
{
    $user = get_userdata($transaction->user_id);
    // user email
    $mail = new AWPCP_Email();
    $mail->to[] = "{$user->display_name} <{$user->user_email}>";
    $mail->subject = get_awpcp_option('paymentabortedsubjectline');
    $template = AWPCP_DIR . '/frontend/templates/email-abort-payment-user.tpl.php';
    $mail->prepare($template, compact('message', 'user', 'transaction'));
    $mail->send();
    // admin email
    $mail = new AWPCP_Email();
    $mail->to[] = awpcp_admin_email_to();
    $mail->subject = __("Customer attempt to pay has failed", "AWPCP");
    $template = AWPCP_DIR . '/frontend/templates/email-abort-payment-admin.tpl.php';
    $mail->prepare($template, compact('message', 'user', 'transaction'));
    $mail->send();
}
Пример #8
0
function awpcp_ad_awaiting_approval_email($ad, $ad_approve, $images_approve)
{
    // admin email
    $params = array('page' => 'awpcp-listings', 'action' => 'manage-images', 'id' => $ad->ad_id);
    $manage_images_url = add_query_arg(urlencode_deep($params), admin_url('admin.php'));
    if (false == $ad_approve && $images_approve) {
        $subject = __('Images on Ad "%s" are awaiting approval', 'AWPCP');
        $message = __('Images on Ad "%s" are awaiting approval. You can approve the images going to the Manage Images section for that Ad and clicking the "Enable" button below each image. Click here to continue: %s.', 'AWPCP');
        $messages = array(sprintf($message, $ad->get_title(), $manage_images_url));
    } else {
        $subject = __('The Ad "%s" is awaiting approval', 'AWPCP');
        $message = __('The Ad "%s" is awaiting approval. You can approve the Ad going to the Manage Listings section and clicking the "Enable" action shown on top. Click here to continue: %s.', 'AWPCP');
        $params = array('page' => 'awpcp-listings', 'action' => 'view', 'id' => $ad->ad_id);
        $url = add_query_arg(urlencode_deep($params), admin_url('admin.php'));
        $messages[] = sprintf($message, $ad->get_title(), $url);
        if ($images_approve) {
            $message = __('Additionally, You can approve the images going to the Manage Images section for that Ad and clicking the "Enable" button below each image. Click here to continue: %s.', 'AWPCP');
            $messages[] = sprintf($message, $manage_images_url);
        }
    }
    $mail = new AWPCP_Email();
    $mail->to[] = awpcp_admin_email_to();
    $mail->subject = sprintf($subject, $ad->get_title());
    $template = AWPCP_DIR . '/frontend/templates/email-ad-awaiting-approval-admin.tpl.php';
    $mail->prepare($template, compact('messages'));
    $mail->send();
}