original_string: public function load_generic_course_sections(stdClass $course, navigation_node $coursenode) {
          global $CFG, $DB, $USER, $SITE;
          require_once($CFG->dirroot.'/course/lib.php');
  
          list($sections, $activities) = $this->generate_sections_and_activities($course);
  
          $navigationsections = array();
          foreach ($sections as $sectionid => $section) {
              $section = clone($section);
              if ($course->id == $SITE->id) {
                  $this->load_section_activities($coursenode, $section->section, $activities);
              } else {
                  if (!$section->uservisible || (!$this->showemptysections &&
                          !$section->hasactivites && $this->includesectionnum !== $section->section)) {
                      continue;
                  }
  
                  $sectionname = get_section_name($course, $section);
                  $url = course_get_url($course, $section->section, array('navigation' => true));
  
                  $sectionnode = $coursenode->add($sectionname, $url, navigation_node::TYPE_SECTION,
                      null, $section->id, new pix_icon('i/section', ''));
                  $sectionnode->nodetype = navigation_node::NODETYPE_BRANCH;
                  $sectionnode->hidden = (!$section->visible || !$section->available);
                  if ($this->includesectionnum !== false && $this->includesectionnum == $section->section) {
                      $this->load_section_activities($sectionnode, $section->section, $activities);
                  }
                  $section->sectionnode = $sectionnode;
                  $navigationsections[$sectionid] = $section;
              }
          }
          return $navigationsections;
      }
code: public function load_generic_course_sections(stdClass $course, navigation_node $coursenode) {
          global $CFG, $DB, $USER, $SITE;
          require_once($CFG->dirroot.'/course/lib.php');
  
          list($sections, $activities) = $this->generate_sections_and_activities($course);
  
          $navigationsections = array();
          foreach ($sections as $sectionid => $section) {
              $section = clone($section);
              if ($course->id == $SITE->id) {
                  $this->load_section_activities($coursenode, $section->section, $activities);
              } else {
                  if (!$section->uservisible || (!$this->showemptysections &&
                          !$section->hasactivites && $this->includesectionnum !== $section->section)) {
                      continue;
                  }
  
                  $sectionname = get_section_name($course, $section);
                  $url = course_get_url($course, $section->section, array('navigation' => true));
  
                  $sectionnode = $coursenode->add($sectionname, $url, navigation_node::TYPE_SECTION,
                      null, $section->id, new pix_icon('i/section', ''));
                  $sectionnode->nodetype = navigation_node::NODETYPE_BRANCH;
                  $sectionnode->hidden = (!$section->visible || !$section->available);
                  if ($this->includesectionnum !== false && $this->includesectionnum == $section->section) {
                      $this->load_section_activities($sectionnode, $section->section, $activities);
                  }
                  $section->sectionnode = $sectionnode;
                  $navigationsections[$sectionid] = $section;
              }
          }
          return $navigationsections;
      }
code_tokens: public function load_generic_course_sections ( stdClass $ course , navigation_node $ coursenode ) { global $ CFG , $ DB , $ USER , $ SITE ; require_once ( $ CFG -> dirroot . '/course/lib.php' ) ; list ( $ sections , $ activities ) = $ this -> generate_sections_and_activities ( $ course ) ; $ navigationsections = array ( ) ; foreach ( $ sections as $ sectionid => $ section ) { $ section = clone ( $ section ) ; if ( $ course -> id == $ SITE -> id ) { $ this -> load_section_activities ( $ coursenode , $ section -> section , $ activities ) ; } else { if ( ! $ section -> uservisible || ( ! $ this -> showemptysections && ! $ section -> hasactivites && $ this -> includesectionnum !== $ section -> section ) ) { continue ; } $ sectionname = get_section_name ( $ course , $ section ) ; $ url = course_get_url ( $ course , $ section -> section , array ( 'navigation' => true ) ) ; $ sectionnode = $ coursenode -> add ( $ sectionname , $ url , navigation_node :: TYPE_SECTION , null , $ section -> id , new pix_icon ( 'i/section' , '' ) ) ; $ sectionnode -> nodetype = navigation_node :: NODETYPE_BRANCH ; $ sectionnode -> hidden = ( ! $ section -> visible || ! $ section -> available ) ; if ( $ this -> includesectionnum !== false && $ this -> includesectionnum == $ section -> section ) { $ this -> load_section_activities ( $ sectionnode , $ section -> section , $ activities ) ; } $ section -> sectionnode = $ sectionnode ; $ navigationsections [ $ sectionid ] = $ section ; } } return $ navigationsections ; }
docstring: Generically loads the course sections into the course's navigation.
  
  @param stdClass $course
  @param navigation_node $coursenode
  @return array An array of course section nodes
docstring_tokens: Generically loads the course sections into the course s navigation .