protected function _dispatch($default = null) { $ad = $this->get_ad(); if (is_null($ad)) { $message = __("The specified Ad doesn't exist or you reached this page directly, without specifying the Ad ID.", 'AWPCP'); return $this->render('content', awpcp_print_error($message)); } else { if (!$ad->is_about_to_expire() && !$ad->has_expired()) { $message = __("The specified Ad doesn't need to be renewed.", 'AWPCP'); return $this->render('content', awpcp_print_error($message)); } else { if (!$this->verify_renew_ad_hash($ad)) { $message = __("There was an error trying to renew your Ad. The URL is not valid. Please contact the Administrator of this site for further assistance.", 'AWPCP'); return $this->render('content', awpcp_print_error($message)); } } } $transaction = $this->get_transaction(); if (!is_null($transaction) && $transaction->get('context') != $this->context) { $page_name = awpcp_get_page_name('renew-ad-page-name'); $page_url = awpcp_get_renew_ad_url($ad->ad_id); $message = __('You are trying to post an Ad using a transaction created for a different purpose. Pelase go back to the <a href="%s">%s</a> page.<br>If you think this is an error please contact the administrator and provide the following transaction ID: %s', 'AWPCP'); $message = sprintf($message, $page_url, $page_name, $transaction->id); return $this->render('content', awpcp_print_error($message)); } $action = $this->get_current_action($default); if (!is_null($transaction) && $transaction->is_payment_completed()) { if (!$transaction->was_payment_successful()) { $message = __('You can\'t renew your Ad at this time because the payment associated with this transaction failed (see reasons below).', 'AWPCP'); $message = awpcp_print_message($message); $message = $message . awpcp_payments_api()->render_transaction_errors($transaction); return $this->render('content', $message); } $forbidden = in_array($action, array('order', 'checkout')); if ($forbidden) { $action = 'payment-completed'; } } if (!is_null($transaction) && $transaction->is_completed()) { $action = 'finish'; } $implementation = $this->get_renew_ad_page_implementation($ad); if (is_null($implementation)) { $message = __("The Ad was posted under a Payment Term that no longer exists or is disabled. The Ad can't be renewed.", 'AWPCP'); $content = '<p>' . $this->get_return_link($ad) . '</p>'; return $this->render('content', awpcp_print_error($message) . $content); } switch ($action) { case 'order': return $implementation->order_step(); case 'checkout': return $implementation->checkout_step(); case 'payment-completed': return $implementation->payment_completed_step(); case 'finish': return $implementation->finish_step(); default: return $implementation->order_step(); } }
public function render_body($listing) { $introduction = $this->settings->get_option('renew-ad-email-body'); if (strpos($introduction, '%d') !== false) { $days_before_listing_expires = $this->days_before_listing_expires($listing); $introduction = sprintf(str_replace('%d', '%s', $introduction), $days_before_listing_expires); } $renew_url = urldecode(awpcp_get_renew_ad_url($listing->ad_id)); ob_start(); include AWPCP_DIR . '/templates/email/listing-is-about-to-expire-notification.plain.tpl.php'; $content = ob_get_contents(); ob_end_clean(); return $content; }
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); } } }