original_string: protected function get_courses($hiddencats) {
          global $DB, $CFG;
          require_once($CFG->libdir.'/modinfolib.php');
  
          $params = array('category' => $this->category->id, 'contextlevel' => CONTEXT_COURSE);
          $sql = 'c.category = :category';
  
          foreach ($hiddencats as $category) {
              $catcontext = context_coursecat::instance($category->id);
              $sql .= ' OR ' . $DB->sql_like('ctx.path', ':path' . $category->id);
              $params['path' . $category->id] = $catcontext->path . '/%';
          }
  
          // Let's retrieve only minimum number of fields from course table -
          // what is needed to check access or call get_fast_modinfo().
          $coursefields = array_merge(['id', 'visible'], course_modinfo::$cachedfields);
          $fields = 'c.' . join(',c.', $coursefields) . ', ' .
              context_helper::get_preload_record_columns_sql('ctx');
          return $DB->get_records_sql('SELECT ' . $fields . ' FROM {course} c
                  JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)
                  WHERE ('.$sql.') ORDER BY c.sortorder', $params);
      }
code: protected function get_courses($hiddencats) {
          global $DB, $CFG;
          require_once($CFG->libdir.'/modinfolib.php');
  
          $params = array('category' => $this->category->id, 'contextlevel' => CONTEXT_COURSE);
          $sql = 'c.category = :category';
  
          foreach ($hiddencats as $category) {
              $catcontext = context_coursecat::instance($category->id);
              $sql .= ' OR ' . $DB->sql_like('ctx.path', ':path' . $category->id);
              $params['path' . $category->id] = $catcontext->path . '/%';
          }
  
          // Let's retrieve only minimum number of fields from course table -
          // what is needed to check access or call get_fast_modinfo().
          $coursefields = array_merge(['id', 'visible'], course_modinfo::$cachedfields);
          $fields = 'c.' . join(',c.', $coursefields) . ', ' .
              context_helper::get_preload_record_columns_sql('ctx');
          return $DB->get_records_sql('SELECT ' . $fields . ' FROM {course} c
                  JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)
                  WHERE ('.$sql.') ORDER BY c.sortorder', $params);
      }
code_tokens: protected function get_courses ( $ hiddencats ) { global $ DB , $ CFG ; require_once ( $ CFG -> libdir . '/modinfolib.php' ) ; $ params = array ( 'category' => $ this -> category -> id , 'contextlevel' => CONTEXT_COURSE ) ; $ sql = 'c.category = :category' ; foreach ( $ hiddencats as $ category ) { $ catcontext = context_coursecat :: instance ( $ category -> id ) ; $ sql .= ' OR ' . $ DB -> sql_like ( 'ctx.path' , ':path' . $ category -> id ) ; $ params [ 'path' . $ category -> id ] = $ catcontext -> path . '/%' ; } // Let's retrieve only minimum number of fields from course table - // what is needed to check access or call get_fast_modinfo(). $ coursefields = array_merge ( [ 'id' , 'visible' ] , course_modinfo :: $ cachedfields ) ; $ fields = 'c.' . join ( ',c.' , $ coursefields ) . ', ' . context_helper :: get_preload_record_columns_sql ( 'ctx' ) ; return $ DB -> get_records_sql ( 'SELECT ' . $ fields . ' FROM {course} c
                  JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)
                  WHERE (' . $ sql . ') ORDER BY c.sortorder' , $ params ) ; }
docstring: List of courses in this category and in hidden subcategories
  
  @param array $hiddencats list of categories that are hidden from current user and returned by {@link get_categories()}
  @return array list of courses
docstring_tokens: List of courses in this category and in hidden subcategories