original_string: private function can_skip(file_info $fileinfo, $extensions, $parent = -1) {
          global $CFG;
          if (!$fileinfo->is_directory()) {
              // do not skip files
              return false;
          }
          if ($fileinfo instanceof file_info_context_course ||
              $fileinfo instanceof file_info_context_user ||
              $fileinfo instanceof file_info_area_course_legacy ||
              $fileinfo instanceof file_info_context_module ||
              $fileinfo instanceof file_info_context_system) {
              // These instances can never be filearea inside an activity, they will never be skipped.
              return false;
          } else if ($fileinfo instanceof file_info_context_coursecat) {
              // This is a course category. For non-admins we do not display categories
              return empty($CFG->navshowmycoursecategories) &&
                              !has_capability('moodle/course:update', context_system::instance());
          } else {
              $params = $fileinfo->get_params();
              if (strlen($params['filearea']) &&
                      ($params['filepath'] === '/' || empty($params['filepath'])) &&
                      ($params['filename'] === '.' || empty($params['filename'])) &&
                      context::instance_by_id($params['contextid'])->contextlevel == CONTEXT_MODULE) {
                  if ($parent === -1) {
                      $parent = $fileinfo->get_parent();
                  }
                  // This is a filearea inside an activity, it can be skipped if it has no non-empty siblings
                  if ($parent && ($parent instanceof file_info_context_module)) {
                      if ($parent->count_non_empty_children($extensions, 2) <= 1) {
                          return true;
                      }
                  }
              }
          }
          return false;
      }
code: private function can_skip(file_info $fileinfo, $extensions, $parent = -1) {
          global $CFG;
          if (!$fileinfo->is_directory()) {
              // do not skip files
              return false;
          }
          if ($fileinfo instanceof file_info_context_course ||
              $fileinfo instanceof file_info_context_user ||
              $fileinfo instanceof file_info_area_course_legacy ||
              $fileinfo instanceof file_info_context_module ||
              $fileinfo instanceof file_info_context_system) {
              // These instances can never be filearea inside an activity, they will never be skipped.
              return false;
          } else if ($fileinfo instanceof file_info_context_coursecat) {
              // This is a course category. For non-admins we do not display categories
              return empty($CFG->navshowmycoursecategories) &&
                              !has_capability('moodle/course:update', context_system::instance());
          } else {
              $params = $fileinfo->get_params();
              if (strlen($params['filearea']) &&
                      ($params['filepath'] === '/' || empty($params['filepath'])) &&
                      ($params['filename'] === '.' || empty($params['filename'])) &&
                      context::instance_by_id($params['contextid'])->contextlevel == CONTEXT_MODULE) {
                  if ($parent === -1) {
                      $parent = $fileinfo->get_parent();
                  }
                  // This is a filearea inside an activity, it can be skipped if it has no non-empty siblings
                  if ($parent && ($parent instanceof file_info_context_module)) {
                      if ($parent->count_non_empty_children($extensions, 2) <= 1) {
                          return true;
                      }
                  }
              }
          }
          return false;
      }
code_tokens: private function can_skip ( file_info $ fileinfo , $ extensions , $ parent = - 1 ) { global $ CFG ; if ( ! $ fileinfo -> is_directory ( ) ) { // do not skip files return false ; } if ( $ fileinfo instanceof file_info_context_course || $ fileinfo instanceof file_info_context_user || $ fileinfo instanceof file_info_area_course_legacy || $ fileinfo instanceof file_info_context_module || $ fileinfo instanceof file_info_context_system ) { // These instances can never be filearea inside an activity, they will never be skipped. return false ; } else if ( $ fileinfo instanceof file_info_context_coursecat ) { // This is a course category. For non-admins we do not display categories return empty ( $ CFG -> navshowmycoursecategories ) && ! has_capability ( 'moodle/course:update' , context_system :: instance ( ) ) ; } else { $ params = $ fileinfo -> get_params ( ) ; if ( strlen ( $ params [ 'filearea' ] ) && ( $ params [ 'filepath' ] === '/' || empty ( $ params [ 'filepath' ] ) ) && ( $ params [ 'filename' ] === '.' || empty ( $ params [ 'filename' ] ) ) && context :: instance_by_id ( $ params [ 'contextid' ] ) -> contextlevel == CONTEXT_MODULE ) { if ( $ parent === - 1 ) { $ parent = $ fileinfo -> get_parent ( ) ; } // This is a filearea inside an activity, it can be skipped if it has no non-empty siblings if ( $ parent && ( $ parent instanceof file_info_context_module ) ) { if ( $ parent -> count_non_empty_children ( $ extensions , 2 ) <= 1 ) { return true ; } } } } return false ; }
docstring: Whether this folder may be skipped in folder hierarchy
  
  1. Skip the name of a single filearea in a module
  2. Skip course categories for non-admins who do not have navshowmycoursecategories setting
  
  @param file_info $fileinfo
  @param string|array $extensions, for example '*' or array('.gif','.jpg')
  @param file_info|int $parent specify parent here if we know it to avoid creating extra objects
  @return bool
docstring_tokens: Whether this folder may be skipped in folder hierarchy