original_string: protected function process_response($response, $limit = 0, $skipaccesscheck = false) {
          global $USER;
  
          if (empty($response)) {
              return array();
          }
  
          if (isset($response->grouped)) {
              return $this->grouped_files_process_response($response, $limit);
          }
  
          $userid = $USER->id;
          $noownerid = \core_search\manager::NO_OWNER_ID;
  
          $numgranted = 0;
  
          if (!$docs = $response->response->docs) {
              return array();
          }
  
          $out = array();
          if (!empty($response->response->numFound)) {
              $this->add_highlight_content($response);
  
              // Iterate through the results checking its availability and whether they are available for the user or not.
              foreach ($docs as $key => $docdata) {
                  if ($docdata['owneruserid'] != $noownerid && $docdata['owneruserid'] != $userid) {
                      // If owneruserid is set, no other user should be able to access this record.
                      continue;
                  }
  
                  if (!$searcharea = $this->get_search_area($docdata->areaid)) {
                      continue;
                  }
  
                  $docdata = $this->standarize_solr_obj($docdata);
  
                  if ($skipaccesscheck) {
                      $access = \core_search\manager::ACCESS_GRANTED;
                  } else {
                      $access = $searcharea->check_access($docdata['itemid']);
                  }
                  switch ($access) {
                      case \core_search\manager::ACCESS_DELETED:
                          $this->delete_by_id($docdata['id']);
                          // Remove one from our processed and total counters, since we promptly deleted.
                          $this->processeddocs--;
                          $this->totalenginedocs--;
                          break;
                      case \core_search\manager::ACCESS_DENIED:
                          $this->skippeddocs++;
                          break;
                      case \core_search\manager::ACCESS_GRANTED:
                          $numgranted++;
  
                          // Add the doc.
                          $out[] = $this->to_document($searcharea, $docdata);
                          break;
                  }
  
                  // Stop when we hit our limit.
                  if (!empty($limit) && count($out) >= $limit) {
                      break;
                  }
              }
          }
  
          return $out;
      }
code: protected function process_response($response, $limit = 0, $skipaccesscheck = false) {
          global $USER;
  
          if (empty($response)) {
              return array();
          }
  
          if (isset($response->grouped)) {
              return $this->grouped_files_process_response($response, $limit);
          }
  
          $userid = $USER->id;
          $noownerid = \core_search\manager::NO_OWNER_ID;
  
          $numgranted = 0;
  
          if (!$docs = $response->response->docs) {
              return array();
          }
  
          $out = array();
          if (!empty($response->response->numFound)) {
              $this->add_highlight_content($response);
  
              // Iterate through the results checking its availability and whether they are available for the user or not.
              foreach ($docs as $key => $docdata) {
                  if ($docdata['owneruserid'] != $noownerid && $docdata['owneruserid'] != $userid) {
                      // If owneruserid is set, no other user should be able to access this record.
                      continue;
                  }
  
                  if (!$searcharea = $this->get_search_area($docdata->areaid)) {
                      continue;
                  }
  
                  $docdata = $this->standarize_solr_obj($docdata);
  
                  if ($skipaccesscheck) {
                      $access = \core_search\manager::ACCESS_GRANTED;
                  } else {
                      $access = $searcharea->check_access($docdata['itemid']);
                  }
                  switch ($access) {
                      case \core_search\manager::ACCESS_DELETED:
                          $this->delete_by_id($docdata['id']);
                          // Remove one from our processed and total counters, since we promptly deleted.
                          $this->processeddocs--;
                          $this->totalenginedocs--;
                          break;
                      case \core_search\manager::ACCESS_DENIED:
                          $this->skippeddocs++;
                          break;
                      case \core_search\manager::ACCESS_GRANTED:
                          $numgranted++;
  
                          // Add the doc.
                          $out[] = $this->to_document($searcharea, $docdata);
                          break;
                  }
  
                  // Stop when we hit our limit.
                  if (!empty($limit) && count($out) >= $limit) {
                      break;
                  }
              }
          }
  
          return $out;
      }
code_tokens: protected function process_response ( $ response , $ limit = 0 , $ skipaccesscheck = false ) { global $ USER ; if ( empty ( $ response ) ) { return array ( ) ; } if ( isset ( $ response -> grouped ) ) { return $ this -> grouped_files_process_response ( $ response , $ limit ) ; } $ userid = $ USER -> id ; $ noownerid = \ core_search \ manager :: NO_OWNER_ID ; $ numgranted = 0 ; if ( ! $ docs = $ response -> response -> docs ) { return array ( ) ; } $ out = array ( ) ; if ( ! empty ( $ response -> response -> numFound ) ) { $ this -> add_highlight_content ( $ response ) ; // Iterate through the results checking its availability and whether they are available for the user or not. foreach ( $ docs as $ key => $ docdata ) { if ( $ docdata [ 'owneruserid' ] != $ noownerid && $ docdata [ 'owneruserid' ] != $ userid ) { // If owneruserid is set, no other user should be able to access this record. continue ; } if ( ! $ searcharea = $ this -> get_search_area ( $ docdata -> areaid ) ) { continue ; } $ docdata = $ this -> standarize_solr_obj ( $ docdata ) ; if ( $ skipaccesscheck ) { $ access = \ core_search \ manager :: ACCESS_GRANTED ; } else { $ access = $ searcharea -> check_access ( $ docdata [ 'itemid' ] ) ; } switch ( $ access ) { case \ core_search \ manager :: ACCESS_DELETED : $ this -> delete_by_id ( $ docdata [ 'id' ] ) ; // Remove one from our processed and total counters, since we promptly deleted. $ this -> processeddocs -- ; $ this -> totalenginedocs -- ; break ; case \ core_search \ manager :: ACCESS_DENIED : $ this -> skippeddocs ++ ; break ; case \ core_search \ manager :: ACCESS_GRANTED : $ numgranted ++ ; // Add the doc. $ out [ ] = $ this -> to_document ( $ searcharea , $ docdata ) ; break ; } // Stop when we hit our limit. if ( ! empty ( $ limit ) && count ( $ out ) >= $ limit ) { break ; } } } return $ out ; }
docstring: Filters the response on Moodle side.
  
  @param SolrObject $response Solr object containing the response return from solr server.
  @param int        $limit The maximum number of results to return. 0 for all.
  @param bool       $skipaccesscheck Don't use check_access() on results. Only to be used when results have known access.
  @return array $results containing final results to be displayed.
docstring_tokens: Filters the response on Moodle side .