original_string: public static function export_user_data(approved_contextlist $contextlist) {
          global $DB;
  
          // Export oauth2 linked accounts.
          $context = \context_user::instance($contextlist->get_user()->id);
          $sql = "SELECT ll.id, ll.username, ll.email, ll.timecreated, ll.timemodified, oi.name as issuername
                  FROM {auth_oauth2_linked_login} ll JOIN {oauth2_issuer} oi ON oi.id = ll.issuerid
                  WHERE ll.userid = :userid";
          if ($oauth2accounts = $DB->get_records_sql($sql, ['userid' => $contextlist->get_user()->id])) {
              foreach ($oauth2accounts as $oauth2account) {
                  $data = (object)[
                      'timecreated' => transform::datetime($oauth2account->timecreated),
                      'timemodified' => transform::datetime($oauth2account->timemodified),
                      'issuerid' => $oauth2account->issuername,
                      'username' => $oauth2account->username,
                      'email' => $oauth2account->email
                  ];
                  writer::with_context($context)->export_data([
                          get_string('privacy:metadata:auth_oauth2', 'auth_oauth2'),
                          $oauth2account->issuername
                      ], $data);
              }
          }
      }
code: public static function export_user_data(approved_contextlist $contextlist) {
          global $DB;
  
          // Export oauth2 linked accounts.
          $context = \context_user::instance($contextlist->get_user()->id);
          $sql = "SELECT ll.id, ll.username, ll.email, ll.timecreated, ll.timemodified, oi.name as issuername
                  FROM {auth_oauth2_linked_login} ll JOIN {oauth2_issuer} oi ON oi.id = ll.issuerid
                  WHERE ll.userid = :userid";
          if ($oauth2accounts = $DB->get_records_sql($sql, ['userid' => $contextlist->get_user()->id])) {
              foreach ($oauth2accounts as $oauth2account) {
                  $data = (object)[
                      'timecreated' => transform::datetime($oauth2account->timecreated),
                      'timemodified' => transform::datetime($oauth2account->timemodified),
                      'issuerid' => $oauth2account->issuername,
                      'username' => $oauth2account->username,
                      'email' => $oauth2account->email
                  ];
                  writer::with_context($context)->export_data([
                          get_string('privacy:metadata:auth_oauth2', 'auth_oauth2'),
                          $oauth2account->issuername
                      ], $data);
              }
          }
      }
code_tokens: public static function export_user_data ( approved_contextlist $ contextlist ) { global $ DB ; // Export oauth2 linked accounts. $ context = \ context_user :: instance ( $ contextlist -> get_user ( ) -> id ) ; $ sql = "SELECT ll.id, ll.username, ll.email, ll.timecreated, ll.timemodified, oi.name as issuername
                  FROM {auth_oauth2_linked_login} ll JOIN {oauth2_issuer} oi ON oi.id = ll.issuerid
                  WHERE ll.userid = :userid" ; if ( $ oauth2accounts = $ DB -> get_records_sql ( $ sql , [ 'userid' => $ contextlist -> get_user ( ) -> id ] ) ) { foreach ( $ oauth2accounts as $ oauth2account ) { $ data = ( object ) [ 'timecreated' => transform :: datetime ( $ oauth2account -> timecreated ) , 'timemodified' => transform :: datetime ( $ oauth2account -> timemodified ) , 'issuerid' => $ oauth2account -> issuername , 'username' => $ oauth2account -> username , 'email' => $ oauth2account -> email ] ; writer :: with_context ( $ context ) -> export_data ( [ get_string ( 'privacy:metadata:auth_oauth2' , 'auth_oauth2' ) , $ oauth2account -> issuername ] , $ data ) ; } } }
docstring: Export all oauth2 information for the list of contexts and this user.
  
  @param  approved_contextlist $contextlist The list of approved contexts for a user.
docstring_tokens: Export all oauth2 information for the list of contexts and this user .