Example #1
0
 /**
  * Returns a list of information about each student blog.
  *
  * The blog information will be returned as an array, with keys of user IDs.
  * Each key's values will be an object with the following attributes:
  *
  *     blog_id - the possible ID of the blog
  *     url     - the URL of the blog
  *
  * If running in multisite mode, `blog_id` will be the ID of the user's
  * blog.  If running in single-site mode, however, it will be null, as only
  * one blog exists, and the blog URL is of the author archive page.
  *
  * @return array information on all student blogs
  *
  * @since 0.5
  */
 public static function get_student_blogs()
 {
     $blogs = array();
     // Cycle through every student
     foreach (self::get_student_user_ids() as $student_id) {
         // Add the first non-root blog on which the student is an admin if
         // running in multisite mode, or use their author archive URL if
         // running in single-site mode
         $blog_info = array();
         if (ClassBlogs_Utils::is_multisite()) {
             foreach (ClassBlogs_Utils::get_non_root_blog_ids() as $blog_id) {
                 $admins = get_users("blog_id={$blog_id}&include={$student_id}&role=administrator");
                 if (count($admins) == 1) {
                     $blog_info = array('blog_id' => $blog_id, 'url' => ClassBlogs_NXTClass::get_blogaddress_by_id($blog_id));
                     break;
                 }
             }
         } else {
             $blog_info = array('blog_id' => null, 'url' => get_author_posts_url($student_id));
         }
         if (!empty($blog_info)) {
             $blogs[$student_id] = (object) $blog_info;
         }
     }
     return $blogs;
 }