original_string: public function find_users($search) {
          global $DB;
          list($wherecondition, $params) = $this->search_sql($search, 'u');
          $params['badgeid'] = $this->badgeid;
          $params['issuerrole'] = $this->issuerrole;
  
          list($esql, $eparams) = get_enrolled_sql($this->context, 'moodle/badges:earnbadge', 0, true);
          $fields = $this->required_fields_sql('u');
          list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);
  
          $params = array_merge($params, $eparams, $sortparams);
          $recipients = $DB->get_records_sql("SELECT $fields
                  FROM {user} u
                  JOIN ($esql) je ON je.id = u.id
                  JOIN {badge_manual_award} s ON s.recipientid = u.id
                  WHERE $wherecondition AND s.badgeid = :badgeid AND s.issuerrole = :issuerrole
                  ORDER BY $sort", $params);
  
          return array(get_string('existingrecipients', 'badges') => $recipients);
      }
code: public function find_users($search) {
          global $DB;
          list($wherecondition, $params) = $this->search_sql($search, 'u');
          $params['badgeid'] = $this->badgeid;
          $params['issuerrole'] = $this->issuerrole;
  
          list($esql, $eparams) = get_enrolled_sql($this->context, 'moodle/badges:earnbadge', 0, true);
          $fields = $this->required_fields_sql('u');
          list($sort, $sortparams) = users_order_by_sql('u', $search, $this->accesscontext);
  
          $params = array_merge($params, $eparams, $sortparams);
          $recipients = $DB->get_records_sql("SELECT $fields
                  FROM {user} u
                  JOIN ($esql) je ON je.id = u.id
                  JOIN {badge_manual_award} s ON s.recipientid = u.id
                  WHERE $wherecondition AND s.badgeid = :badgeid AND s.issuerrole = :issuerrole
                  ORDER BY $sort", $params);
  
          return array(get_string('existingrecipients', 'badges') => $recipients);
      }
code_tokens: public function find_users ( $ search ) { global $ DB ; list ( $ wherecondition , $ params ) = $ this -> search_sql ( $ search , 'u' ) ; $ params [ 'badgeid' ] = $ this -> badgeid ; $ params [ 'issuerrole' ] = $ this -> issuerrole ; list ( $ esql , $ eparams ) = get_enrolled_sql ( $ this -> context , 'moodle/badges:earnbadge' , 0 , true ) ; $ fields = $ this -> required_fields_sql ( 'u' ) ; list ( $ sort , $ sortparams ) = users_order_by_sql ( 'u' , $ search , $ this -> accesscontext ) ; $ params = array_merge ( $ params , $ eparams , $ sortparams ) ; $ recipients = $ DB -> get_records_sql ( "SELECT $fields
                  FROM {user} u
                  JOIN ($esql) je ON je.id = u.id
                  JOIN {badge_manual_award} s ON s.recipientid = u.id
                  WHERE $wherecondition AND s.badgeid = :badgeid AND s.issuerrole = :issuerrole
                  ORDER BY $sort" , $ params ) ; return array ( get_string ( 'existingrecipients' , 'badges' ) => $ recipients ) ; }
docstring: Finds all users who already have been awarded a badge by current role
  
  @param string $search
  @return array
docstring_tokens: Finds all users who already have been awarded a badge by current role