function notify_user($packet, $nomore = false) { if (isset($this->nomore_email) && $this->nomore_email) { return; } $this->nomore_email = $nomore; global $ym_res; $user = get_userdata($packet['user_id']); $message_id = ''; // make sure its an int if ($packet['status']) { $packet['status'] = 1; } else { $packet['status'] = 0; } if (isset($packet['post_id']) && $packet['post_id']) { $message_id = 'post_' . $packet['status']; } else { if (isset($packet['ppack_id']) && $packet['ppack_id']) { $message_id = 'ppack_' . $packet['status']; } else { $message_id = 'pack_' . $packet['status']; } } $target = $subject = $message = $target_scan = ''; $do = FALSE; if (method_exists($this, 'messages')) { // if data returned then send email here // otherwise no send or payment gateway handles // data returns message to send $data = $this->messages($message_id, $user, $packet); if ($data) { $target = $data['to']; $subject = $data['subject']; $message = $data['message']; $target_scan = $data['target_scan']; $do = TRUE; } } else { $target = $user->display_name . ' <' . $user->user_email . '>'; $display_name = $user->display_name; // use default messages switch ($message_id) { case 'post_1': if ($ym_res->payment_gateway_enable_post_success) { $do = TRUE; } $target_scan = 'payment_gateway_email_post_success'; $posttitle = get_the_title($packet['post_id']); $posttitle = strip_tags($posttitle); $postlink = get_permalink($packet['post_id']); $subject = $ym_res->payment_gateway_subject_post_success; $subject = str_replace('[blogname]', get_option('blogname'), $subject); $subject = str_replace('[post_title]', $posttitle, $subject); $message = $ym_res->payment_gateway_message_post_success; $message = str_replace('[display_name]', $display_name, $message); $message = str_replace('[post_title]', $posttitle, $message); $message = str_replace('[post_link]', $postlink, $message); $message = str_replace('[blogname]', get_option('blogname'), $message); break; case 'post_0': if ($ym_res->payment_gateway_enable_post_failed) { $do = TRUE; } $target_scan = 'payment_gateway_email_post_failed'; $posttitle = get_the_title($packet['post_id']); $posttitle = strip_tags($posttitle); $subject = $ym_res->payment_gateway_subject_post_failed; $subject = str_replace('[blogname]', get_option('blogname'), $subject); $subject = str_replace('[post_title]', $posttitle, $subject); $message = $ym_res->payment_gateway_message_post_failed; $message = str_replace('[display_name]', $display_name, $message); $message = str_replace('[post_title]', $posttitle, $message); $message = str_replace('[blogname]', get_option('blogname'), $message); break; case 'ppack_1': if ($ym_res->payment_gateway_enable_ppack_success) { $do = TRUE; } $target_scan = 'payment_gateway_email_ppack_success'; $pack_data = ym_get_bundle($packet['ppack_id']); $posts = ym_get_bundle_posts($packet['ppack_id']); $post_urls = ''; foreach ($posts as $post) { $post_urls .= '<a href="' . get_permalink($post->post_id) . '">' . get_the_title($post->post_id) . '</a><br />'; } $subject = $ym_res->payment_gateway_subject_ppack_success; $subject = str_replace('[blogname]', get_option('blogname'), $subject); $subject = str_replace('[pack_title]', $pack_data->name, $subject); $message = $ym_res->payment_gateway_message_ppack_success; $message = str_replace('[display_name]', $display_name, $message); $message = str_replace('[pack_name]', $pack_data->name, $message); $message = str_replace('[posts_in_pack]', $post_urls, $message); $message = str_replace('[blogname]', get_option('blogname'), $message); break; case 'ppack_0': if ($ym_res->payment_gateway_enable_ppack_failed) { $do = TRUE; } $target_scan = 'payment_gateway_email_ppack_failed'; $pack_data = ym_get_bundle($packet['ppack_id']); $subject = $ym_res->payment_gateway_subject_ppack_failed; $subject = str_replace('[blogname]', get_option('blogname'), $subject); $subject = str_replace('[pack_title]', $pack_data->name, $subject); $message = $ym_res->payment_gateway_message_ppack_failed; $message = str_replace('[display_name]', $display_name, $message); $message = str_replace('[pack_name]', $pack_data->name, $message); $message = str_replace('[blogname]', get_option('blogname'), $message); break; case 'pack_1': if ($ym_res->payment_gateway_enable_subscription_success) { $do = TRUE; } $target_scan = 'payment_gateway_email_subscription_success'; $label = ym_get_pack_label($packet['pack_id']); $label = strip_tags($label); $user = new YourMember_User($packet['user_id']); $expire = $user->expire_date; $f = YM_DATE; $expire = date($f, $expire); $subject = $ym_res->payment_gateway_subject_subscription_success; $subject = str_replace('[blogname]', get_option('blogname'), $subject); $subject = str_replace('[pack_label]', $label, $subject); $message = $ym_res->payment_gateway_message_subscription_success; $message = str_replace('[display_name]', $display_name, $message); $message = str_replace('[pack_label]', $label, $message); $message = str_replace('[pack_expire]', $expire, $message); $message = str_replace('[blogname]', get_option('blogname'), $message); break; case 'pack_0': if ($ym_res->payment_gateway_enable_subscription_failed) { $do = TRUE; } $target_scan = 'payment_gateway_email_subscription_failed'; $label = ym_get_pack_label($packet['pack_id']); $label = strip_tags($label); $subject = $ym_res->payment_gateway_subject_subscription_failed; $subject = str_replace('[blogname]', get_option('blogname'), $subject); $subject = str_replace('[pack_label]', $label, $subject); $message = $ym_res->payment_gateway_message_subscription_failed; $message = str_replace('[display_name]', $display_name, $message); $message = str_replace('[pack_label]', $label, $message); $message = str_replace('[blogname]', get_option('blogname'), $message); break; } } remove_all_shortcodes(); // login user to alow shortcodes to behave wp_set_current_user($packet['user_id']); // apply ym_user_custom shortcode add_shortcode('ym_user_is', 'ym_user_is'); add_shortcode('ym_user_is_not', 'ym_user_is_not'); add_shortcode('ym_user_custom', 'ym_shortcode_user'); $message = do_shortcode($message); // transaction log ID global $ym_this_transaction_id; $log_id = 'YMTRANS_' . $ym_this_transaction_id; $message = str_replace('[ym_log_id]', $log_id, $message); $message_prepend = __('This is a copy of a Message not sent', 'ym'); if ($do) { ym_email($target, $subject, $message); $message_prepend = __('This is a copy of a Message sent', 'ym'); } // additional targets? if (is_array($ym_res->{$target_scan})) { $subject = 'CC: ' . $subject; $message = $message_prepend . '<br /><br />' . $message; foreach ($ym_res->{$target_scan} as $target) { if ($target) { ym_email($target, $subject, $message); } } } }
/** Render purchases show_content is whether to show the bundle (false) or the bundle and the posts in it TRUE */ function ym_render_my_purchased_bundles($user_id, $show_expiries = FALSE, $show_content = TRUE, $with_snippets = TRUE) { global $wpdb; $html = ''; $query = 'SELECT * FROM ' . $wpdb->prefix . 'ym_post_packs_purchased yppp LEFT JOIN ' . $wpdb->prefix . 'ym_post_pack ypp ON ypp.id = yppp.pack_id WHERE user_id = ' . $user_id; $results = $wpdb->get_results($query); if ($results) { $html .= '<table cellspacing="0" class="ym_ppp_page"><tr><th>' . __('Bundle Title', 'ym') . '</th>' . ($show_expiries ? '<th>' . __('Access Expiry', 'ym') . '</th>' : '') . ($show_content ? '<th></th>' : '') . '</tr>'; foreach ($results as $row) { $html .= '<tr><td>' . $row->name . '</td>' . ($show_expiries ? '<td>' . ym_get_bundle_expiry_date($row->pack_id, $user_id) . '</td>' : '') . '</tr>'; if ($show_content) { $posts = ym_get_bundle_posts($row->pack_id); $html .= '<tr><td></td><td colspan="4"><table><tr><th>' . __('Post Title', 'ym') . '</th><th>' . __('Published', 'ym') . '</th></tr>'; foreach ($posts as $post) { $post = get_post($post->post_id); $link = get_permalink($post->ID); $title = $post->post_title; $published = date(YM_DATE, strtotime($post->post_date)); if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) { $title = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($title); } $html .= '<tr><td><a href="' . $link . '">' . $title . '</a></td><td>' . $published . '</td></tr>'; if ($with_snippets) { $full_content = apply_filters('the_content', $post->post_content); $content = substr(strip_tags($full_content), 0, $snippet_length); $html .= '<tr><td></td><td colspan="' . ($show_expiries ? 3 : 2) . '" class="ym_ppp_page_excerpt">' . $content . '</td></tr>'; } } $html .= '</table></td></tr>'; } } $html .= '</table>'; } return $html; }
function ym_bundle_meta_box($post) { global $wpdb; echo '<p>' . __('You can add/remove this Post to a Content Bundle, it needs to be set as Purchasable under the Content Purchase Widget', 'ym') . '</p>'; $in_bundle = array(); $query = 'SELECT pack_id FROM ' . $wpdb->prefix . 'ym_post_pack_post_assoc WHERE post_id = ' . $post->ID; foreach ($wpdb->get_results($query) as $row) { $in_bundle[] = $row->pack_id; } $in_bundle = array_unique($in_bundle); $bundles = ym_get_bundles(); foreach ($bundles as $bundle) { echo $bundle->name . ' '; $rows = ym_get_bundle_posts($bundle->id); $count = count($rows); echo '(' . $count . ' ' . __('Posts in pack', 'ym') . ') '; echo '<input type="checkbox" name="ym_bundle[]" value="' . $bundle->id . '" '; if (in_array($bundle->id, $in_bundle)) { echo 'checked="checked"'; } echo ' />'; echo '<br />'; } }
<th></th> </tr> </thead> <tbody> '; if ($bundles = ym_get_bundles()) { foreach ($bundles as $i => $bundle) { $bundle->additional = unserialize($bundle->additional); $string = array(); if (is_array($bundle->additional)) { foreach ($bundle->additional as $key => $val) { $string[] = str_replace('_', ' ', $key) . ': ' . $val; } } $string = implode('<br />', $string); $posts = count(ym_get_bundle_posts($bundle->id)); echo '<tr>'; echo '<td>(' . $bundle->id . ') ' . $bundle->name . '</td>'; echo '<td>' . number_format($bundle->cost, 2) . '</td>'; echo '<td>' . $bundle->description . '</td>'; echo '<td>'; echo $string; echo '</td>'; echo '<td>' . ($bundle->purchaseexpire ? $bundle->purchaseexpire . ' ' . __('Day(s)', 'ym') : __('None', 'ym')) . '</td>'; echo '<td>' . ($bundle->purchaselimit ? ym_bundle_purchased_count($bundle->bundle_id) . '/' . $bundle->purchaselimit : __('None', 'ym')) . '</td>'; echo '<td>' . ($bundle->saleend ? date(YM_DATE, $bundle->saleend) : __('None', 'ym')) . '</td>'; echo '<td>' . date(YM_DATE, $bundle->unixtime) . '</td>'; echo '<td>'; echo ' <form action="" method="post"> <input type="hidden" name="bundle_id" value="' . $bundle->id . '" />