Exemplo n.º 1
0
    /**
     * Shows a professor a list of all student comments.
     *
     * @uses ClassBlogs_Plugins_StudentBlogList to get student blog URLs
     *
     * @access private
     * @since 0.2
     */
    public function _admin_page()
    {
        global $blog_id;
        $current_blog_id = $blog_id;
        // Create a lookup table of student data keyed by blog ID for multisite mode
        $students = array();
        if (ClassBlogs_Utils::is_multisite()) {
            foreach (ClassBlogs_Students::get_student_blogs() as $student_id => $blog) {
                $user_data = get_userdata($student_id);
                $students[$blog->blog_id] = array('blog_url' => $blog->url, 'name' => sprintf('%s %s', $user_data->first_name, $user_data->last_name));
            }
        }
        // Paginate the comment data
        $comments = $this->get_sitewide_comments(false);
        $paginator = new ClassBlogs_Paginator($comments, self::COMMENTS_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 Comments', 'classblogs');
        ?>
</h2>

			<p>
				<?php 
        _e("This page allows you to view all of the comments that have been left on yours students' blogs.", 'classblogs');
        ?>
			</p>

			<?php 
        $paginator->show_admin_page_links($current_page);
        ?>

			<table class="widefat cb-cw-comments-table" id="cb-sw-student-comments-list">

				<thead>
					<tr>
						<th class="author"><?php 
        _e('Author', 'classblogs');
        ?>
</th>
						<th class="content"><?php 
        _e('Comment', 'classblogs');
        ?>
</th>
						<th class="post"><?php 
        _e('Post', 'classblogs');
        ?>
</th>
						<?php 
        if (ClassBlogs_Utils::is_multisite()) {
            ?>
							<th class="student"><?php 
            _e('Student Blog', 'classblogs');
            ?>
</th>
						<?php 
        }
        ?>
						<th class="status"><?php 
        _e('Status', 'classblogs');
        ?>
</th>
						<th class="posted"><?php 
        _e('Date', 'classblogs');
        ?>
</th>
					</tr>
				</thead>

				<tfoot>
					<tr>
						<th class="author"><?php 
        _e('Author', 'classblogs');
        ?>
</th>
						<th class="content"><?php 
        _e('Comment', 'classblogs');
        ?>
</th>
						<th class="post"><?php 
        _e('Post', 'classblogs');
        ?>
</th>
						<?php 
        if (ClassBlogs_Utils::is_multisite()) {
            ?>
							<th class="student"><?php 
            _e('Student Blog', 'classblogs');
            ?>
</th>
						<?php 
        }
        ?>
						<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="author">
									<?php 
            printf('%s <strong>%s</strong> <br /> <a href="mailto:%s">%s</a>', get_avatar($comment->comment_author_email, 32), esc_html($comment->comment_author), esc_attr($comment->comment_author_email), esc_html($comment->comment_author_email));
            ?>
							</td>
							<td class="content">
								<?php 
            comment_text($comment->comment_ID);
            ?>
							</td>
							<td class="post">
								<strong>
									<?php 
            printf('<a href="%s">%s</a>', esc_url(ClassBlogs_NXTClass::get_blog_permalink($comment->cb_sw_blog_id, $comment->comment_post_ID)), esc_html($comment->post_title));
            ?>
								</strong>
							</td>
							<?php 
            if (ClassBlogs_Utils::is_multisite()) {
                ?>
								<td class="student">
									<strong>
										<?php 
                if (array_key_exists($comment->cb_sw_blog_id, $students)) {
                    $blog = $students[$comment->cb_sw_blog_id];
                    printf('<a href="%s">%s</a>', esc_url($blog['blog_url']), esc_html($blog['name']));
                }
                ?>
									</strong>
								</td>
							<?php 
            }
            ?>
							<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 
    }
Exemplo n.º 2
0
 /**
  * Returns a list of information about each student blog.
  *
  * The blogs in the returned list will be sorted by the last and then
  * first name of the student owning it.  Each item in this list will be
  * an object with the following properties:
  *
  *     blog_id - the ID of the blog
  *     name    - the formatted display name of the blog
  *     user_id - the ID of the student who owns the blog
  *     url     - the URL of the blog
  *
  * @param  string $format the formatting string to use for the blog title
  * @return array          a list of information on all student blogs
  *
  * @since 0.1
  */
 public function get_student_blogs($title_format = "")
 {
     // Use cached data if possible
     $cached = $this->get_site_cache('student_blogs');
     if ($cached !== null) {
         return $cached;
     }
     // Format the display of the
     $student_blogs = array();
     foreach (ClassBlogs_Students::get_student_blogs() as $student_id => $blog) {
         $student_blogs[$student_id] = (object) array('blog_id' => $blog->blog_id, 'name' => $this->_format_blog_display_name($title_format, $student_id, $blog->blog_id), 'user_id' => $student_id, 'url' => $blog->url);
     }
     // Return the blogs sorted by their computed display name
     usort($student_blogs, array($this, "_sort_blogs_by_name"));
     $this->set_site_cache('student_blogs', $student_blogs, 300);
     return $student_blogs;
 }
Exemplo n.º 3
0
    /**
     * 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 
    }