/**
  * builds list of children of a given category
  * @access public static
  * @param int parent_id ID of category
  * array of objects of all children
  */
 static function build_children_list($parent_id, $attached_type = NULL)
 {
     Logger::log("Enter: function Category::build_children_list");
     $cat_obj = new category_item_list();
     $position = Category::get_position($parent_id);
     if ($position) {
         $sql = "SELECT * FROM {categories} WHERE position RLIKE  '^" . $position . "[0-9]+>\$'";
         $res = Dal::query($sql);
         $total_threads = NULL;
         if ($res->numRows() > 0) {
             while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
                 //         $total_threads = MessageBoard::get_threads_count_of_category($row->category_id);
                 if ($attached_type == 'MessageBoard') {
                     $total_threads = MessageBoard::get_threads_count_of_category($row->category_id);
                 }
                 if ($attached_type == 'Default') {
                     $total_threads = Group::get_threads_count_of_category($row->category_id);
                 }
                 if ($attached_type == 'Network') {
                     $total_threads = Network::get_threads_count_of_category($row->category_id);
                 }
                 $category_item = new category_item($row->category_id, $row->name, $row->description, $total_threads, $row->position, $row->type);
                 $cat_obj->add_cat_item($category_item);
             }
         }
         $cat_list = $cat_obj->get_cat_list();
     } else {
         $cat_list = '';
     }
     Logger::log("Exit: function Category::build_children_list");
     return $cat_list;
 }