/** * Renders the student-only page showing all a list of all comments that * they have left on other blogs on the site. * * @access private * @since 0.2 */ public function _student_admin_page() { global $blog_id; $current_blog_id = $blog_id; $student_id = nxt_get_current_user()->ID; // Create a lookup table for blog names and URLs $all_blogs = array(); foreach (ClassBlogs_Utils::get_all_blog_ids() as $blog_id) { $all_blogs[$blog_id] = array('name' => ClassBlogs_NXTClass::get_blog_option($blog_id, 'blogname'), 'url' => ClassBlogs_NXTClass::get_blogaddress_by_id($blog_id)); } // Paginate the data, restricting the data set to only comments that the // current student wrote $comments = array(); foreach ($this->get_sitewide_comments(false) as $comment) { if ((int) $comment->user_id === $student_id) { $comments[] = $comment; } } $paginator = new ClassBlogs_Paginator($comments, self::COMMENTS_PER_ADMIN_PAGE); $current_page = array_key_exists('paged', $_GET) ? absint($_GET['paged']) : 1; ?> <div class="wrap"> <div id="icon-edit-comments" class="icon32"></div> <h2><?php _e('My Comments', 'classblogs'); ?> </h2> <p> <?php _e("This page allows you to view all of the comments that you have left on other students' blogs.", 'classblogs'); ?> </p> <?php $paginator->show_admin_page_links($current_page); ?> <table class="widefat cb-sw-comments-table" id="cb-sw-my-comments-list"> <thead> <tr> <th class="blog"><?php _e('Blog', 'classblogs'); ?> </th> <th class="post"><?php _e('Post', 'classblogs'); ?> </th> <th class="content"><?php _e('Content', 'classblogs'); ?> </th> <th class="status"><?php _e('Status', 'classblogs'); ?> </th> <th class="posted"><?php _e('Date', 'classblogs'); ?> </th> </tr> </thead> <tfoot> <tr> <th class="blog"><?php _e('Blog', 'classblogs'); ?> </th> <th class="post"><?php _e('Post', 'classblogs'); ?> </th> <th class="content"><?php _e('Content', 'classblogs'); ?> </th> <th class="status"><?php _e('Status', 'classblogs'); ?> </th> <th class="posted"><?php _e('Date', 'classblogs'); ?> </th> </tr> </tfoot> <tbody> <?php foreach ($paginator->get_items_for_page($current_page) as $comment) { ClassBlogs_NXTClass::switch_to_blog($comment->cb_sw_blog_id); $status = nxt_get_comment_status($comment->comment_ID); ?> <tr class="<?php echo $status; ?> "> <td class="blog"> <strong> <?php printf('<a href="%s">%s</a>', esc_url($all_blogs[$comment->cb_sw_blog_id]['url']), esc_html($all_blogs[$comment->cb_sw_blog_id]['name'])); ?> </strong> </td> <td class="post"> <strong> <?php printf('<a href="%s">%s</a>', esc_url(get_comment_link($comment)), esc_html($comment->post_title)); ?> </strong> </td> <td class="content"> <?php comment_text($comment->comment_ID); ?> </td> <td class="status"> <?php if ($status == 'approved') { _e('Approved', 'classblogs'); } elseif ($status == 'deleted' || $status == 'trash') { _e('Deleted', 'classblogs'); } elseif ($status == 'spam') { _e('Spam', 'classblogs'); } elseif ($status == 'unapproved') { _e('Unapproved', 'classblogs'); } else { _e('Unknown', 'classblogs'); } ?> </td> <td class="posted"> <?php printf('<span class="date">%s</span> <span class="time">%s</span>', mysql2date(get_option('date_format'), $comment->comment_date), mysql2date(get_option('time_format'), $comment->comment_date)); ?> </td> </tr> <?php } ClassBlogs_Utils::restore_blog($current_blog_id); ?> </tbody> </table> <?php $paginator->show_admin_page_links($current_page, 'bottom'); ?> </div> <?php }
/** * Shows a professor a list of student posts. * * @uses ClassBlogs_Plugins_StudentBlogList to get student blog URLs * * @access private * @since 0.2 */ public function _posts_admin_page() { // Create a lookup table for student names and blogs keyed by user ID $students = array(); foreach (ClassBlogs_Students::get_student_blogs() as $student_id => $blog) { $user_data = get_userdata($student_id); $students[$student_id] = array('blog_url' => $blog->url, 'name' => sprintf('%s %s', $user_data->first_name, $user_data->last_name)); } // Paginate the data, restricting the data set to student-only posts $student_posts = array(); foreach ($this->get_sitewide_posts() as $post) { if (array_key_exists($post->post_author, $students)) { $student_posts[] = $post; } } $paginator = new ClassBlogs_Paginator($student_posts, self::POSTS_PER_ADMIN_PAGE); $current_page = array_key_exists('paged', $_GET) ? absint($_GET['paged']) : 1; ?> <div class="wrap"> <?php ClassBlogs_Admin::show_admin_icon(); ?> <h2><?php _e('Student Posts', 'classblogs'); ?> </h2> <p> <?php _e('This page allows you to view all of the posts that your students have published.', 'classblogs'); ?> </p> <?php $paginator->show_admin_page_links($current_page); ?> <table class="widefat" id="cb-sw-student-posts-list"> <thead> <tr> <th class="student"><?php _e('Student', 'classblogs'); ?> </th> <th class="post"><?php _e('Post', 'classblogs'); ?> </th> <th class="excerpt"><?php _e('Excerpt', 'classblogs'); ?> </th> <th class="posted"><?php _e('Posted', 'classblogs'); ?> </th> </tr> </thead> <tfoot> <tr> <th class="student"><?php _e('Student', 'classblogs'); ?> </th> <th class="post"><?php _e('Post', 'classblogs'); ?> </th> <th class="excerpt"><?php _e('Excerpt', 'classblogs'); ?> </th> <th class="posted"><?php _e('Posted', 'classblogs'); ?> </th> </tr> </tfoot> <tbody> <?php foreach ($paginator->get_items_for_page($current_page) as $post) { ?> <tr> <td class="student"> <strong> <?php echo get_avatar($post->post_author, 32) . ' '; printf('<a href="%s">%s</a>', $students[$post->post_author]['blog_url'], $students[$post->post_author]['name']); ?> </strong> </td> <td class="post"> <strong> <?php printf('<a href="%s">%s</a>', ClassBlogs_NXTClass::get_blog_permalink($post->cb_sw_blog_id, $post->ID), $post->post_title); ?> </strong> </td> <td class="excerpt"><?php echo ClassBlogs_Utils::make_post_excerpt($post->post_content, 25); ?> </td> <td class="posted"> <?php echo mysql2date(get_option('date_format'), $post->post_date); ?> </td> </tr> <?php } ?> </tbody> </table> <?php $paginator->show_admin_page_links($current_page, 'bottom'); ?> </div> <?php }