original_string: protected static function export_user_data_contacts(int $userid) {
          global $DB;
  
          $context = \context_user::instance($userid);
  
          // Get the user's contacts.
          if ($contacts = $DB->get_records_select('message_contacts', 'userid = ? OR contactid = ?', [$userid, $userid], 'id ASC')) {
              $contactdata = [];
              foreach ($contacts as $contact) {
                  $contactdata[] = (object) [
                      'contact' => transform::user($contact->contactid)
                  ];
              }
              writer::with_context($context)->export_data([get_string('contacts', 'core_message')], (object) $contactdata);
          }
      }
code: protected static function export_user_data_contacts(int $userid) {
          global $DB;
  
          $context = \context_user::instance($userid);
  
          // Get the user's contacts.
          if ($contacts = $DB->get_records_select('message_contacts', 'userid = ? OR contactid = ?', [$userid, $userid], 'id ASC')) {
              $contactdata = [];
              foreach ($contacts as $contact) {
                  $contactdata[] = (object) [
                      'contact' => transform::user($contact->contactid)
                  ];
              }
              writer::with_context($context)->export_data([get_string('contacts', 'core_message')], (object) $contactdata);
          }
      }
code_tokens: protected static function export_user_data_contacts ( int $ userid ) { global $ DB ; $ context = \ context_user :: instance ( $ userid ) ; // Get the user's contacts. if ( $ contacts = $ DB -> get_records_select ( 'message_contacts' , 'userid = ? OR contactid = ?' , [ $ userid , $ userid ] , 'id ASC' ) ) { $ contactdata = [ ] ; foreach ( $ contacts as $ contact ) { $ contactdata [ ] = ( object ) [ 'contact' => transform :: user ( $ contact -> contactid ) ] ; } writer :: with_context ( $ context ) -> export_data ( [ get_string ( 'contacts' , 'core_message' ) ] , ( object ) $ contactdata ) ; } }
docstring: Export the messaging contact data.
  
  @param int $userid
docstring_tokens: Export the messaging contact data .