original_string: public static function get_user_acceptances($userid, $versions = null) {
          global $DB;
  
          list($vsql, $vparams) = ['', []];
          if (!empty($versions)) {
              list($vsql, $vparams) = $DB->get_in_or_equal($versions, SQL_PARAMS_NAMED, 'ver');
              $vsql = ' AND a.policyversionid ' . $vsql;
          }
  
          $userfieldsmod = get_all_user_name_fields(true, 'm', null, 'mod');
          $sql = "SELECT u.id AS mainuserid, a.policyversionid, a.status, a.lang, a.timemodified, a.usermodified, a.note,
                    u.policyagreed, $userfieldsmod
                    FROM {user} u
                    INNER JOIN {tool_policy_acceptances} a ON a.userid = u.id AND a.userid = :userid $vsql
                    LEFT JOIN {user} m ON m.id = a.usermodified";
          $params = ['userid' => $userid];
          $result = $DB->get_recordset_sql($sql, $params + $vparams);
  
          $acceptances = [];
          foreach ($result as $row) {
              if (!empty($row->policyversionid)) {
                  $acceptances[$row->policyversionid] = $row;
              }
          }
          $result->close();
  
          return $acceptances;
      }
code: public static function get_user_acceptances($userid, $versions = null) {
          global $DB;
  
          list($vsql, $vparams) = ['', []];
          if (!empty($versions)) {
              list($vsql, $vparams) = $DB->get_in_or_equal($versions, SQL_PARAMS_NAMED, 'ver');
              $vsql = ' AND a.policyversionid ' . $vsql;
          }
  
          $userfieldsmod = get_all_user_name_fields(true, 'm', null, 'mod');
          $sql = "SELECT u.id AS mainuserid, a.policyversionid, a.status, a.lang, a.timemodified, a.usermodified, a.note,
                    u.policyagreed, $userfieldsmod
                    FROM {user} u
                    INNER JOIN {tool_policy_acceptances} a ON a.userid = u.id AND a.userid = :userid $vsql
                    LEFT JOIN {user} m ON m.id = a.usermodified";
          $params = ['userid' => $userid];
          $result = $DB->get_recordset_sql($sql, $params + $vparams);
  
          $acceptances = [];
          foreach ($result as $row) {
              if (!empty($row->policyversionid)) {
                  $acceptances[$row->policyversionid] = $row;
              }
          }
          $result->close();
  
          return $acceptances;
      }
code_tokens: public static function get_user_acceptances ( $ userid , $ versions = null ) { global $ DB ; list ( $ vsql , $ vparams ) = [ '' , [ ] ] ; if ( ! empty ( $ versions ) ) { list ( $ vsql , $ vparams ) = $ DB -> get_in_or_equal ( $ versions , SQL_PARAMS_NAMED , 'ver' ) ; $ vsql = ' AND a.policyversionid ' . $ vsql ; } $ userfieldsmod = get_all_user_name_fields ( true , 'm' , null , 'mod' ) ; $ sql = "SELECT u.id AS mainuserid, a.policyversionid, a.status, a.lang, a.timemodified, a.usermodified, a.note,
                    u.policyagreed, $userfieldsmod
                    FROM {user} u
                    INNER JOIN {tool_policy_acceptances} a ON a.userid = u.id AND a.userid = :userid $vsql
                    LEFT JOIN {user} m ON m.id = a.usermodified" ; $ params = [ 'userid' => $ userid ] ; $ result = $ DB -> get_recordset_sql ( $ sql , $ params + $ vparams ) ; $ acceptances = [ ] ; foreach ( $ result as $ row ) { if ( ! empty ( $ row -> policyversionid ) ) { $ acceptances [ $ row -> policyversionid ] = $ row ; } } $ result -> close ( ) ; return $ acceptances ; }
docstring: Returns list of acceptances for this user.
  
  @param int $userid id of a user.
  @param int|array $versions list of policy versions.
  @return array list of acceptances indexed by versionid.
docstring_tokens: Returns list of acceptances for this user .