function ym_membership_content_page($with_boxes = false, $with_snippets = TRUE, $with_expires = FALSE, $show = 'posts,bundles,premium')
{
    get_currentuserinfo();
    global $current_user, $wpdb, $ym_res;
    $snippet_length = 200;
    $max_loops = 30;
    $html = '';
    $membership_level = ym_get_user_package_type($current_user->ID);
    $posts = false;
    $show = explode(',', $show);
    if (in_array('posts', $show)) {
        if ($pp = ym_render_my_purchased_posts($current_user->ID, false, true, $with_expires, $with_snippets)) {
            if ($with_boxes) {
                $html .= ym_start_box(__('My Purchased Posts', 'ym'));
            }
            $html .= $pp;
            if ($with_boxes) {
                $html .= ym_end_box();
            }
        }
    }
    if (in_array('bundles', $show)) {
        // bundle
        if ($bundles = ym_render_my_purchased_bundles($current_user->ID, $with_expires, TRUE, $with_snippets)) {
            if ($with_boxes) {
                $html .= ym_start_box(__('My Purchased Bundles', 'ym'));
            }
            $html .= $bundles;
            if ($with_boxes) {
                $html .= ym_end_box();
            }
        }
    }
    if (in_array('premium', $show)) {
        $sql = 'SELECT DISTINCT(ID), post_title, post_date, post_content
				FROM
					' . $wpdb->posts . ' p
					JOIN ' . $wpdb->postmeta . ' pm ON (
						p.ID = pm.post_id
						AND p.post_status = "publish"
						AND pm.meta_key = "_ym_account_type"
						AND pm.meta_value LIKE "%' . $membership_level . '%"
						AND post_type = "post"
					)
				ORDER BY post_date DESC';
        $results = $wpdb->get_results($sql);
        $loops = 0;
        if ($members_pages = count($results)) {
            foreach ($results as $id => $obj) {
                if (!ym_user_has_access($obj->ID)) {
                    $membership_pages--;
                    continue;
                }
                $published = date(YM_DATEFORMAT, strtotime($obj->post_date));
                $full_content = apply_filters('the_content', $obj->post_content);
                $title = $obj->post_title;
                if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
                    $title = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($title);
                    $full_content = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($full_content);
                }
                $row = '<tr>
				<td style="border-top: 1px solid silver;">
					<div style="margin-bottom: 5px;"><a href="' . get_permalink($obj->ID) . '">' . $title . '</a></div>
					';
                if ($with_snippets) {
                    $content = substr(strip_tags($full_content), 0, $snippet_length);
                    //$content = preg_replace("'\[/?\s?private\s?\]'i",'', $content);
                    $ending = strlen($full_content) > strip_tags($snippet_length) ? '...' : '';
                    $row .= '<div style="font-size: 10px; margin-bottom: 5px;">' . $content . $ending . '</div>';
                }
                $row .= '
				</td>
				<td style="vertical-align: top; border-top: 1px solid silver;">' . $published . '</td>
			</tr>';
                $posts .= $row;
                $loops++;
                if ($loops >= $max_loops) {
                    break;
                }
            }
        }
        $table_intro = 'Showing the most recent ' . $loops . ' posts of a total ' . $members_pages . ' available to you.';
        $html .= $ym_res->members_content_divider_html;
        if ($with_boxes) {
            $html .= ym_start_box(__('Premium Content', 'ym'));
        }
        $html .= '	<div class="premium_content_intro">' . __('Your membership level is:', "ym") . ' <strong>' . $membership_level . '</strong>. 	
				' . __('You have access to a total of', "ym") . ' ' . $members_pages . ' ' . __('premium', 'ym') . ' ' . ($members_pages == 1 ? __('post', 'ym') : __('posts', 'ym')) . ' 
			</div>';
        if ($members_pages > 0) {
            $html .= $table_intro;
            $html .= '<div style="padding-top: 10px; margin-bottom: 10px;">
				<table style="width: 100%" cellspacing="0" cellpadding="2">
				<tr>
					<th style="text-align: left;">Post Title</th>
					<th style="width: 160px; text-align: left;">Published</th>
				</tr>
					' . $posts . '
			</table></div>';
        }
        if ($with_boxes) {
            $html .= ym_end_box();
        }
    }
    return $html;
}
 function widget($args, $instance)
 {
     get_currentuserinfo();
     global $current_user;
     extract($args);
     $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
     $text = trim(apply_filters('widget_text', $instance['text'], $instance));
     if ($current_user->ID) {
         echo $before_widget;
         if (!empty($title)) {
             echo $before_title . $title . $after_title;
         }
         if ($text) {
             echo '<p>' . $text . '</p>';
         }
         echo '<div class="ym_ppp_widget">';
         ym_render_my_purchased_posts($current_user->ID, true, false, @$instance['show_expiry']);
         echo '</div>';
         echo $after_widget;
     }
 }