Otherwise known as, please clean up this script.
The only step specific to the Silverpop export is to create silverpop_export_view. Everything else should be pushed into sibling modules:
- Dedupe
- Geo and language cleanup
- Communication preferences consulted using a conservative OR: opted_out.
- Find latest contribution
We want these cached values to be available from CiviCRM, so maybe package the extracted code as a CiviCRM extension, wrap in custom groups, and keep the data up to date using triggers.