Example #1
0
function doadexpirations()
{
    global $wpdb, $nameofsite;
    $notify_admin = get_awpcp_option('notifyofadexpired');
    $notify_expiring = get_awpcp_option('notifyofadexpiring');
    // disable the ads or delete the ads?
    // 1 = disable, 0 = delete
    $disable_ads = get_awpcp_option('autoexpiredisabledelete');
    // allow users to use %s placeholder for the website name in the subject line
    $subject = get_awpcp_option('adexpiredsubjectline');
    $subject = sprintf($subject, $nameofsite);
    $bodybase = get_awpcp_option('adexpiredbodymessage');
    $admin_sender_email = awpcp_admin_sender_email_address();
    $admin_recipient_email = awpcp_admin_recipient_email_address();
    $ads = AWPCP_Ad::find("ad_enddate <= NOW() AND disabled != 1 AND payment_status != 'Unpaid' AND verified = 1");
    foreach ($ads as $ad) {
        $ad->disable();
        if ($notify_expiring == false && $notify_admin == false) {
            continue;
        }
        $adtitle = get_adtitle($ad->ad_id);
        $adstartdate = date("D M j Y G:i:s", strtotime(get_adstartdate($ad->ad_id)));
        $body = $bodybase;
        $body .= "\n\n";
        $body .= __("Listing Details", "AWPCP");
        $body .= "\n\n";
        $body .= __("Ad Title:", "AWPCP");
        $body .= " {$adtitle}";
        $body .= "\n\n";
        $body .= __("Posted:", "AWPCP");
        $body .= " {$adstartdate}";
        $body .= "\n\n";
        $body .= __("Renew your ad by visiting:", "AWPCP");
        $body .= " " . urldecode(awpcp_get_renew_ad_url($ad->ad_id));
        $body .= "\n\n";
        if ($notify_expiring) {
            $user_email = get_adposteremail($ad->ad_id);
            if (!empty($user_email)) {
                awpcp_process_mail($admin_sender_email, $user_email, $subject, $body, $nameofsite, $admin_recipient_email);
            }
        }
        if ($notify_admin) {
            awpcp_process_mail($admin_sender_email, $admin_recipient_email, $subject, $body, $nameofsite, $admin_recipient_email);
        }
    }
}
Example #2
0
 protected function process_contact_form()
 {
     global $nameofsite;
     $ad = $this->get_ad();
     $form = array_merge($this->get_posted_data(), array('ad_id' => $ad->ad_id));
     $errors = array();
     if (!$this->validate_posted_data($form, $errors)) {
         return $this->contact_form($form, $errors);
     }
     $ad_title = $ad->get_title();
     $ad_url = url_showad($ad->ad_id);
     $sender_name = stripslashes($form['awpcp_sender_name']);
     $sender_email = stripslashes($form['awpcp_sender_email']);
     $message = awpcp_strip_html_tags(stripslashes($form['awpcp_contact_message']));
     if (get_awpcp_option('usesenderemailinsteadofadmin')) {
         $sender = awpcp_strip_html_tags($sender_name);
         $from = $sender_email;
     } else {
         $sender = $nameofsite;
         $from = awpcp_admin_sender_email_address();
     }
     /* send email to admin */
     if (get_awpcp_option('notify-admin-about-contact-message')) {
         $subject = __('Notification about a response regarding Ad: %s', 'AWPCP');
         $subject = sprintf($subject, $ad_title);
         ob_start();
         include AWPCP_DIR . '/frontend/templates/email-reply-to-ad-admin.tpl.php';
         $admin_body = ob_get_contents();
         ob_end_clean();
         $admin_email = awpcp_admin_recipient_email_address();
         $result = awpcp_process_mail($from, $admin_email, $subject, $admin_body, $sender, $sender_email);
     }
     $subject = sprintf("%s %s: %s", get_awpcp_option('contactformsubjectline'), _x('regarding', 'reply email', 'AWPCP'), $ad_title);
     ob_start();
     include AWPCP_DIR . '/frontend/templates/email-reply-to-ad-user.tpl.php';
     $body = ob_get_contents();
     ob_end_clean();
     $sendtoemail = get_adposteremail($ad->ad_id);
     $result = awpcp_process_mail($from, $sendtoemail, trim($subject), $body, $sender, $sender_email);
     if ($result) {
         $message = __("Your message has been sent.", "AWPCP");
         return $this->render('content', awpcp_print_message($message));
     } else {
         $this->messages[] = __("There was a problem encountered during the attempt to send your message. Please try again and if the problem persists, please contact the system administrator.", "AWPCP");
         return $this->contact_form($form, $errors);
     }
 }
Example #3
0
/**
 * Return the name and email address of the account that appears as the sender in
 * email notifications.
 *
 * @since	3.0
 * @return	string	name <email@address>
 */
function awpcp_admin_email_from()
{
    return awpcp_format_email_address(awpcp_admin_sender_email_address(), awpcp_get_blog_name());
}