original_string: public function frontpage_my_courses() {
          global $USER, $CFG, $DB;
  
          if (!isloggedin() or isguestuser()) {
              return '';
          }
  
          $output = '';
          $courses  = enrol_get_my_courses('summary, summaryformat');
          $rhosts   = array();
          $rcourses = array();
          if (!empty($CFG->mnet_dispatcher_mode) && $CFG->mnet_dispatcher_mode==='strict') {
              $rcourses = get_my_remotecourses($USER->id);
              $rhosts   = get_my_remotehosts();
          }
  
          if (!empty($courses) || !empty($rcourses) || !empty($rhosts)) {
  
              $chelper = new coursecat_helper();
              $totalcount = count($courses);
              if (count($courses) > $CFG->frontpagecourselimit) {
                  // There are more enrolled courses than we can display, display link to 'My courses'.
                  $courses = array_slice($courses, 0, $CFG->frontpagecourselimit, true);
                  $chelper->set_courses_display_options(array(
                          'viewmoreurl' => new moodle_url('/my/'),
                          'viewmoretext' => new lang_string('mycourses')
                      ));
              } else if (core_course_category::top()->is_uservisible()) {
                  // All enrolled courses are displayed, display link to 'All courses' if there are more courses in system.
                  $chelper->set_courses_display_options(array(
                          'viewmoreurl' => new moodle_url('/course/index.php'),
                          'viewmoretext' => new lang_string('fulllistofcourses')
                      ));
                  $totalcount = $DB->count_records('course') - 1;
              }
              $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->
                      set_attributes(array('class' => 'frontpage-course-list-enrolled'));
              $output .= $this->coursecat_courses($chelper, $courses, $totalcount);
  
              // MNET
              if (!empty($rcourses)) {
                  // at the IDP, we know of all the remote courses
                  $output .= html_writer::start_tag('div', array('class' => 'courses'));
                  foreach ($rcourses as $course) {
                      $output .= $this->frontpage_remote_course($course);
                  }
                  $output .= html_writer::end_tag('div'); // .courses
              } elseif (!empty($rhosts)) {
                  // non-IDP, we know of all the remote servers, but not courses
                  $output .= html_writer::start_tag('div', array('class' => 'courses'));
                  foreach ($rhosts as $host) {
                      $output .= $this->frontpage_remote_host($host);
                  }
                  $output .= html_writer::end_tag('div'); // .courses
              }
          }
          return $output;
      }
code: public function frontpage_my_courses() {
          global $USER, $CFG, $DB;
  
          if (!isloggedin() or isguestuser()) {
              return '';
          }
  
          $output = '';
          $courses  = enrol_get_my_courses('summary, summaryformat');
          $rhosts   = array();
          $rcourses = array();
          if (!empty($CFG->mnet_dispatcher_mode) && $CFG->mnet_dispatcher_mode==='strict') {
              $rcourses = get_my_remotecourses($USER->id);
              $rhosts   = get_my_remotehosts();
          }
  
          if (!empty($courses) || !empty($rcourses) || !empty($rhosts)) {
  
              $chelper = new coursecat_helper();
              $totalcount = count($courses);
              if (count($courses) > $CFG->frontpagecourselimit) {
                  // There are more enrolled courses than we can display, display link to 'My courses'.
                  $courses = array_slice($courses, 0, $CFG->frontpagecourselimit, true);
                  $chelper->set_courses_display_options(array(
                          'viewmoreurl' => new moodle_url('/my/'),
                          'viewmoretext' => new lang_string('mycourses')
                      ));
              } else if (core_course_category::top()->is_uservisible()) {
                  // All enrolled courses are displayed, display link to 'All courses' if there are more courses in system.
                  $chelper->set_courses_display_options(array(
                          'viewmoreurl' => new moodle_url('/course/index.php'),
                          'viewmoretext' => new lang_string('fulllistofcourses')
                      ));
                  $totalcount = $DB->count_records('course') - 1;
              }
              $chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->
                      set_attributes(array('class' => 'frontpage-course-list-enrolled'));
              $output .= $this->coursecat_courses($chelper, $courses, $totalcount);
  
              // MNET
              if (!empty($rcourses)) {
                  // at the IDP, we know of all the remote courses
                  $output .= html_writer::start_tag('div', array('class' => 'courses'));
                  foreach ($rcourses as $course) {
                      $output .= $this->frontpage_remote_course($course);
                  }
                  $output .= html_writer::end_tag('div'); // .courses
              } elseif (!empty($rhosts)) {
                  // non-IDP, we know of all the remote servers, but not courses
                  $output .= html_writer::start_tag('div', array('class' => 'courses'));
                  foreach ($rhosts as $host) {
                      $output .= $this->frontpage_remote_host($host);
                  }
                  $output .= html_writer::end_tag('div'); // .courses
              }
          }
          return $output;
      }
code_tokens: public function frontpage_my_courses ( ) { global $ USER , $ CFG , $ DB ; if ( ! isloggedin ( ) or isguestuser ( ) ) { return '' ; } $ output = '' ; $ courses = enrol_get_my_courses ( 'summary, summaryformat' ) ; $ rhosts = array ( ) ; $ rcourses = array ( ) ; if ( ! empty ( $ CFG -> mnet_dispatcher_mode ) && $ CFG -> mnet_dispatcher_mode === 'strict' ) { $ rcourses = get_my_remotecourses ( $ USER -> id ) ; $ rhosts = get_my_remotehosts ( ) ; } if ( ! empty ( $ courses ) || ! empty ( $ rcourses ) || ! empty ( $ rhosts ) ) { $ chelper = new coursecat_helper ( ) ; $ totalcount = count ( $ courses ) ; if ( count ( $ courses ) > $ CFG -> frontpagecourselimit ) { // There are more enrolled courses than we can display, display link to 'My courses'. $ courses = array_slice ( $ courses , 0 , $ CFG -> frontpagecourselimit , true ) ; $ chelper -> set_courses_display_options ( array ( 'viewmoreurl' => new moodle_url ( '/my/' ) , 'viewmoretext' => new lang_string ( 'mycourses' ) ) ) ; } else if ( core_course_category :: top ( ) -> is_uservisible ( ) ) { // All enrolled courses are displayed, display link to 'All courses' if there are more courses in system. $ chelper -> set_courses_display_options ( array ( 'viewmoreurl' => new moodle_url ( '/course/index.php' ) , 'viewmoretext' => new lang_string ( 'fulllistofcourses' ) ) ) ; $ totalcount = $ DB -> count_records ( 'course' ) - 1 ; } $ chelper -> set_show_courses ( self :: COURSECAT_SHOW_COURSES_EXPANDED ) -> set_attributes ( array ( 'class' => 'frontpage-course-list-enrolled' ) ) ; $ output .= $ this -> coursecat_courses ( $ chelper , $ courses , $ totalcount ) ; // MNET if ( ! empty ( $ rcourses ) ) { // at the IDP, we know of all the remote courses $ output .= html_writer :: start_tag ( 'div' , array ( 'class' => 'courses' ) ) ; foreach ( $ rcourses as $ course ) { $ output .= $ this -> frontpage_remote_course ( $ course ) ; } $ output .= html_writer :: end_tag ( 'div' ) ; // .courses } elseif ( ! empty ( $ rhosts ) ) { // non-IDP, we know of all the remote servers, but not courses $ output .= html_writer :: start_tag ( 'div' , array ( 'class' => 'courses' ) ) ; foreach ( $ rhosts as $ host ) { $ output .= $ this -> frontpage_remote_host ( $ host ) ; } $ output .= html_writer :: end_tag ( 'div' ) ; // .courses } } return $ output ; }
docstring: Returns HTML to print list of courses user is enrolled to for the frontpage
  
  Also lists remote courses or remote hosts if MNET authorisation is used
  
  @return string
docstring_tokens: Returns HTML to print list of courses user is enrolled to for the frontpage