original_string: public static function get_user_minors($userid, array $extrafields = null) {
          global $DB;
  
          $ctxfields = context_helper::get_preload_record_columns_sql('c');
          $namefields = get_all_user_name_fields(true, 'u');
          $pixfields = user_picture::fields('u', $extrafields);
  
          $sql = "SELECT $ctxfields, $namefields, $pixfields
                    FROM {role_assignments} ra
                    JOIN {context} c ON c.contextlevel = ".CONTEXT_USER." AND ra.contextid = c.id
                    JOIN {user} u ON c.instanceid = u.id
                   WHERE ra.userid = ?
                ORDER BY u.lastname ASC, u.firstname ASC";
  
          $rs = $DB->get_recordset_sql($sql, [$userid]);
  
          $minors = [];
  
          foreach ($rs as $record) {
              context_helper::preload_from_record($record);
              $childcontext = context_user::instance($record->id);
              if (has_capability('tool/policy:acceptbehalf', $childcontext, $userid)) {
                  $minors[$record->id] = $record;
              }
          }
  
          $rs->close();
  
          return $minors;
      }
code: public static function get_user_minors($userid, array $extrafields = null) {
          global $DB;
  
          $ctxfields = context_helper::get_preload_record_columns_sql('c');
          $namefields = get_all_user_name_fields(true, 'u');
          $pixfields = user_picture::fields('u', $extrafields);
  
          $sql = "SELECT $ctxfields, $namefields, $pixfields
                    FROM {role_assignments} ra
                    JOIN {context} c ON c.contextlevel = ".CONTEXT_USER." AND ra.contextid = c.id
                    JOIN {user} u ON c.instanceid = u.id
                   WHERE ra.userid = ?
                ORDER BY u.lastname ASC, u.firstname ASC";
  
          $rs = $DB->get_recordset_sql($sql, [$userid]);
  
          $minors = [];
  
          foreach ($rs as $record) {
              context_helper::preload_from_record($record);
              $childcontext = context_user::instance($record->id);
              if (has_capability('tool/policy:acceptbehalf', $childcontext, $userid)) {
                  $minors[$record->id] = $record;
              }
          }
  
          $rs->close();
  
          return $minors;
      }
code_tokens: public static function get_user_minors ( $ userid , array $ extrafields = null ) { global $ DB ; $ ctxfields = context_helper :: get_preload_record_columns_sql ( 'c' ) ; $ namefields = get_all_user_name_fields ( true , 'u' ) ; $ pixfields = user_picture :: fields ( 'u' , $ extrafields ) ; $ sql = "SELECT $ctxfields, $namefields, $pixfields
                    FROM {role_assignments} ra
                    JOIN {context} c ON c.contextlevel = " . CONTEXT_USER . " AND ra.contextid = c.id
                    JOIN {user} u ON c.instanceid = u.id
                   WHERE ra.userid = ?
                ORDER BY u.lastname ASC, u.firstname ASC" ; $ rs = $ DB -> get_recordset_sql ( $ sql , [ $ userid ] ) ; $ minors = [ ] ; foreach ( $ rs as $ record ) { context_helper :: preload_from_record ( $ record ) ; $ childcontext = context_user :: instance ( $ record -> id ) ; if ( has_capability ( 'tool/policy:acceptbehalf' , $ childcontext , $ userid ) ) { $ minors [ $ record -> id ] = $ record ; } } $ rs -> close ( ) ; return $ minors ; }
docstring: Return the user's minors - other users on which behalf we can accept policies.
  
  Returned objects contain all the standard user name and picture fields as well as the context instanceid.
  
  @param int $userid The id if the user with parental responsibility
  @param array $extrafields Extra fields to be included in result
  @return array of objects
docstring_tokens: Return the user s minors - other users on which behalf we can accept policies .