unset($GLOBALS['formulize_afterSavingLogicRequired']);
// now that saving is done, we don't need this any longer, so clean up
// set the ownership info of the new entries created...use a custom named handler, so we don't conflict with any other data handlers that might be using the more conventional 'data_handler' name, which can happen depending on the scope within which this file is included
foreach ($formulize_newEntryIds as $newEntryFid => $entries) {
    $data_handler_for_owner_groups = new formulizeDataHandler($newEntryFid);
    $data_handler_for_owner_groups->setEntryOwnerGroups($formulize_newEntryUsers[$newEntryFid], $formulize_newEntryIds[$newEntryFid]);
    unset($data_handler_for_owner_groups);
}
// reassign entry ownership for an entry if the user requested that, and has permission
if (isset($updateOwnerFid) and $gperm_handler->checkRight("update_entry_ownership", $updateOwnerFid, $groups, $mid)) {
    $data_handler_for_owner_updating = new formulizeDataHandler($updateOwnerFid);
    if (!$data_handler_for_owner_updating->setEntryOwnerGroups($updateOwnerNewOwnerId, $updateOwnerEntryId, true)) {
        // final true causes an update, instead of a normal setting of the groups from scratch.  Entry's creation user is updated too.
        print "<b>Error: could not update the entry ownership information.  Please report this to the webmaster right away, including which entry you were trying to update.</b>";
    }
    $data_handler_for_owner_updating->updateCaches($updateOwnerEntryId);
}
// update the derived values for all forms that we saved data for, now that we've saved all the data from all the forms
$form_handler = xoops_getmodulehandler('forms', 'formulize');
$mainFormHasDerived = false;
if ($fid) {
    $mainFormObject = $form_handler->get($fid, true);
    // true causes all elements to be gathered, including ones that are not displayed to the users
    $mainFormHasDerived = array_search("derived", $mainFormObject->getVar('elementTypes'));
}
$mainFormEntriesUpdatedForDerived = array();
$formsUpdatedInFramework = array();
// check all the entries that were written...
foreach ($formulize_allWrittenEntryIds as $allWrittenFid => $entries) {
    $derivedValueFound = false;
    $formObject = $form_handler->get($allWrittenFid, true);