I eventually figured this out. Here's the code that's working for me:
$newFields = array(
0 => '12', // $field->fieldId
1 => '15' // $field->fieldId
);
// First we get all sections and loop through them
$allSections = craft()->sections->getAllSections();
foreach ($allSections as $section)
{
// Then we get all EntryTypes of each section and loop through those
$sectionEntryTypes = $section->getEntryTypes();
foreach ($sectionEntryTypes as $entryType)
{
// Grab the current layout and tabs
$currentLayout = $entryType->getFieldLayout();
$currentTabs = $currentLayout->getTabs();
// This will the array passed to assembleLayout
$postedFieldLayout = array();
// Loop through each tab and build our array
foreach ($currentTabs as $tab) {
$fields = $tab->getFields();
foreach ($fields as $field) {
$postedFieldLayout[$tab->name][] = $field->fieldId;
}
}
// Append the new fields we want to show to that array
$postedFieldLayout['newFields'] = $this->newFields;
$requiredFields = array();
// Assemble the layout
$fieldLayout = craft()->fields->assembleLayout($postedFieldLayout, $requiredFields);
$fieldLayout->type = ElementType::Entry;
$entryType->setFieldLayout($fieldLayout);
// Save it
if (craft()->sections->saveEntryType($entryType))
{
Craft::log('Successfully appended fields.');
}
else
{
Craft::log('Could not append the fields.', LogLevel::Warning);
}
}
}