original_string: protected static function fetch_plugins($plugintype, $fulldir) {
          global $CFG;
  
          $fulldirs = (array)$fulldir;
          if ($plugintype === 'theme') {
              if (realpath($fulldir) !== realpath($CFG->dirroot.'/theme')) {
                  // Include themes in standard location too.
                  array_unshift($fulldirs, $CFG->dirroot.'/theme');
              }
          }
  
          $result = array();
  
          foreach ($fulldirs as $fulldir) {
              if (!is_dir($fulldir)) {
                  continue;
              }
              $items = new \DirectoryIterator($fulldir);
              foreach ($items as $item) {
                  if ($item->isDot() or !$item->isDir()) {
                      continue;
                  }
                  $pluginname = $item->getFilename();
                  if ($plugintype === 'auth' and $pluginname === 'db') {
                      // Special exception for this wrong plugin name.
                  } else if (isset(self::$ignoreddirs[$pluginname])) {
                      continue;
                  }
                  if (!self::is_valid_plugin_name($plugintype, $pluginname)) {
                      // Always ignore plugins with problematic names here.
                      continue;
                  }
                  $result[$pluginname] = $fulldir.'/'.$pluginname;
                  unset($item);
              }
              unset($items);
          }
  
          ksort($result);
          return $result;
      }
code: protected static function fetch_plugins($plugintype, $fulldir) {
          global $CFG;
  
          $fulldirs = (array)$fulldir;
          if ($plugintype === 'theme') {
              if (realpath($fulldir) !== realpath($CFG->dirroot.'/theme')) {
                  // Include themes in standard location too.
                  array_unshift($fulldirs, $CFG->dirroot.'/theme');
              }
          }
  
          $result = array();
  
          foreach ($fulldirs as $fulldir) {
              if (!is_dir($fulldir)) {
                  continue;
              }
              $items = new \DirectoryIterator($fulldir);
              foreach ($items as $item) {
                  if ($item->isDot() or !$item->isDir()) {
                      continue;
                  }
                  $pluginname = $item->getFilename();
                  if ($plugintype === 'auth' and $pluginname === 'db') {
                      // Special exception for this wrong plugin name.
                  } else if (isset(self::$ignoreddirs[$pluginname])) {
                      continue;
                  }
                  if (!self::is_valid_plugin_name($plugintype, $pluginname)) {
                      // Always ignore plugins with problematic names here.
                      continue;
                  }
                  $result[$pluginname] = $fulldir.'/'.$pluginname;
                  unset($item);
              }
              unset($items);
          }
  
          ksort($result);
          return $result;
      }
code_tokens: protected static function fetch_plugins ( $ plugintype , $ fulldir ) { global $ CFG ; $ fulldirs = ( array ) $ fulldir ; if ( $ plugintype === 'theme' ) { if ( realpath ( $ fulldir ) !== realpath ( $ CFG -> dirroot . '/theme' ) ) { // Include themes in standard location too. array_unshift ( $ fulldirs , $ CFG -> dirroot . '/theme' ) ; } } $ result = array ( ) ; foreach ( $ fulldirs as $ fulldir ) { if ( ! is_dir ( $ fulldir ) ) { continue ; } $ items = new \ DirectoryIterator ( $ fulldir ) ; foreach ( $ items as $ item ) { if ( $ item -> isDot ( ) or ! $ item -> isDir ( ) ) { continue ; } $ pluginname = $ item -> getFilename ( ) ; if ( $ plugintype === 'auth' and $ pluginname === 'db' ) { // Special exception for this wrong plugin name. } else if ( isset ( self :: $ ignoreddirs [ $ pluginname ] ) ) { continue ; } if ( ! self :: is_valid_plugin_name ( $ plugintype , $ pluginname ) ) { // Always ignore plugins with problematic names here. continue ; } $ result [ $ pluginname ] = $ fulldir . '/' . $ pluginname ; unset ( $ item ) ; } unset ( $ items ) ; } ksort ( $ result ) ; return $ result ; }
docstring: Returns list of plugins of given type in given directory.
  @param string $plugintype
  @param string $fulldir
  @return array
docstring_tokens: Returns list of plugins of given type in given directory .