public function actions($ad, $filter = false) { $is_moderator = awpcp_current_user_is_moderator(); $actions = array(); $actions['view'] = array(__('View', 'AWPCP'), $this->url(array('action' => 'view', 'id' => $ad->ad_id))); $actions['edit'] = array(__('Edit', 'AWPCP'), $this->url(array('action' => 'edit', 'id' => $ad->ad_id))); $actions['trash'] = array(__('Delete', 'AWPCP'), $this->url(array('action' => 'delete', 'id' => $ad->ad_id))); if ($is_moderator) { if ($ad->disabled) { $actions['enable'] = array(__('Enable', 'AWPCP'), $this->url(array('action' => 'enable', 'id' => $ad->ad_id))); } else { $actions['disable'] = array(__('Disable', 'AWPCP'), $this->url(array('action' => 'disable', 'id' => $ad->ad_id))); } if ($ad->flagged) { $actions['unflag'] = array(__('Unflag', 'AWPCP'), $this->url(array('action' => 'unflag', 'id' => $ad->ad_id))); } if (get_awpcp_option('useakismet')) { $actions['spam'] = array('SPAM', $this->url(array('action' => 'spam', 'id' => $ad->ad_id))); } $has_featured_ads = function_exists('awpcp_featured_ads'); if ($has_featured_ads && $ad->is_featured_ad) { $actions['remove-featured'] = array(__('Remove Featured', 'AWPCP'), $this->url(array('action' => 'remove-featured', 'id' => $ad->ad_id))); } else { if ($has_featured_ads) { $actions['make-featured'] = array(__('Make Featured', 'AWPCP'), $this->url(array('action' => 'make-featured', 'id' => $ad->ad_id))); } } $actions['send-key'] = array(__('Send Access Key', 'AWPCP'), $this->url(array('action' => 'send-key', 'id' => $ad->ad_id))); } if ($ad->is_about_to_expire() || $ad->has_expired()) { $hash = awpcp_get_renew_ad_hash($ad->ad_id); $params = array('action' => 'renew', 'id' => $ad->ad_id, 'awpcprah' => $hash); $actions['renwew-ad'] = array(__('Renew Ad', 'AWPCP'), $this->url($params)); } if ($images = $ad->count_image_files()) { $label = __('Manage Images', 'AWPCP'); $url = $this->url(array('action' => 'manage-images', 'id' => $ad->ad_id)); $actions['manage-images'] = array($label, array('', $url, " ({$images})")); } else { if (awpcp_are_images_allowed()) { $actions['add-image'] = array(__('Add Images', 'AWPCP'), $this->url(array('action' => 'add-image', 'id' => $ad->ad_id))); } } if ($is_moderator && !$ad->disabled) { $fb = AWPCP_Facebook::instance(); if (!awpcp_get_ad_meta($ad->ad_id, 'sent-to-facebook') && $fb->get('page_id')) { $actions['send-to-facebook'] = array(__('Send to Facebook', 'AWPCP'), $this->url(array('action' => 'send-to-facebook', 'id' => $ad->ad_id))); } else { if (!awpcp_get_ad_meta($ad->ad_id, 'sent-to-facebook-group') && $fb->get('group_id')) { $actions['send-to-facebook'] = array(__('Send to Facebook Group', 'AWPCP'), $this->url(array('action' => 'send-to-facebook', 'id' => $ad->ad_id))); } } } $actions = apply_filters('awpcp-admin-listings-table-actions', $actions, $ad, $this); if ($is_moderator && isset($_REQUEST['filterby']) && $_REQUEST['filterby'] == 'new') { $actions['mark-reviewed'] = array(__('Mark Reviewed', 'AWPCP'), $this->url(array('action' => 'mark-reviewed', 'id' => $ad->ad_id))); } if (is_array($filter)) { $actions = array_intersect_key($actions, array_combine($filter, $filter)); } return $actions; }
/** * @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); } }
/** * @since 3.0.2 */ function awpcp_clean_up_non_verified_ads($listings, $settings) { global $wpdb; if (!$settings->get_option('enable-email-verification')) { return; } $resend_email_threshold = $settings->get_option('email-verification-first-threshold'); $delete_ads_threshold = $settings->get_option('email-verification-second-threshold'); // delete Ads that have been in a non-verified state for more than M days $conditions = AWPCP_Ad::get_where_conditions_for_successfully_paid_listings(array('verified = 0', $wpdb->prepare('ad_postdate < ADDDATE( NOW(), INTERVAL -%d DAY )', $delete_ads_threshold))); foreach (AWPCP_Ad::find(join(' AND ', $conditions)) as $ad) { $ad->delete(); } // re-send verificaiton email for Ads that have been in a non-verified state for more than N days $conditions = AWPCP_Ad::get_where_conditions_for_successfully_paid_listings(array('verified = 0', $wpdb->prepare('ad_postdate < ADDDATE( NOW(), INTERVAL -%d DAY )', $resend_email_threshold))); foreach (AWPCP_Ad::find(join(' AND ', $conditions)) as $ad) { if (intval(awpcp_get_ad_meta($ad->ad_id, 'verification_emails_sent', true)) <= 1) { $listings->send_verification_email($ad); } } }
public function get($listing_id, $name) { return awpcp_get_ad_meta($listing_id, $name, true); }