function CACF_CreateModelAuditDataAndWriteToCsv(&$db, &$CACFconstants, &$altiumUserNamesByGuid, &$altiumFoldersByGuid, &$altiumAclDataByObjectGuid, &$altiumItemRevsByGuid)
{
    //  echo "In CACF_CreateModelAuditDataAndWriteToCsv(), auditModelsFileName is \"$auditModelsFileName\".\n";
    /* Retrieve necessary global constants. */
    $auditModelsFileName = $CACFconstants["auditModelsFileName"];
    /* Create model audit data. */
    CACF_CreateModelAuditData(&$db, &$CACFconstants, &$altiumUserNamesByGuid, &$altiumFoldersByGuid, &$altiumAclDataByObjectGuid, &$altiumItemRevsByGuid, &$altiumModelDataByItemRevHrid);
    /* Write audit data to csv file. */
    $auditSpecifiedsFileName = $auditModelsFileName;
    $auditType = "models";
    $altiumSpecifiedDataByItemRevHrid =& $altiumModelDataByItemRevHrid;
    CACF_WriteSpecifiedAuditDataToCsv(&$db, &$CACFconstants, $auditSpecifiedsFileName, &$altiumUserNamesByGuid, &$altiumFoldersByGuid, $auditType, &$altiumItemRevsByGuid, &$altiumSpecifiedDataByItemRevHrid);
}
function UCTCF_InitAndGetVaultData(&$CACFconstants, &$auditComponentsByType, &$auditComponentsByTypeUnmatched, &$UCTCFconstants, $CmpLibFileName, &$altiumFoldersByGuid, &$altiumItemsByGuid, &$altiumItemRevsByGuid, &$altiumModelDataByItemRevHrid, &$altiumUserParmNames, &$altiumItemUserParmValuesByGuid, &$altiumItemSysParmValuesByGuid, &$altiumObsoleteCompsByGuid)
{
    /* Setup some constants for use by this script. */
    $UCTCFconstants = array();
    /* Column widths for new tags in CmpLib XML file. */
    $UCTCFconstants["cNewUserParmColumnWidth"] = "25";
    $UCTCFconstants["cNewModelTypeColumnWidth"] = "50";
    /* Name of default Altium Vault. */
    /* Note:  Company-specific info! */
    $UCTCFconstants["defaultVaultHrid"] = "TRT Satellite Vault";
    /* Name of default Altium Revision Naming Scheme. */
    /* Note:  Company-specific info! */
    $UCTCFconstants["defaultRevisionNamingSchemeHrid"] = "TRT 1-Level Rev Scheme";
    /* Name of default Altium LifeCycle Definition. */
    /* Note:  Company-specific info! */
    $UCTCFconstants["defaultLifeCycleDefinitionHrid"] = "TRT Component Lifecycle";
    /* Constants related to the "StateIndex" CmpLib XML attribute. */
    $UCTCFconstants["cXmlStateName"] = "StateIndex";
    $UCTCFconstants["cXmlStateEnabled"] = "2";
    // Set this to enable a component to be released to Vault
    $UCTCFconstants["cXmlStateSemiEnabled"] = "1";
    // Set this for all folders that are parents of a component in above state.
    $UCTCFconstants["cXmlStateDisabled"] = "0";
    // Set this to disable a component/folder being released to Vault.
    /* Constants related to the "Collapsed" CmpLib XML attribute. */
    $UCTCFconstants["cXmlCollapsedName"] = "Collapsed";
    $UCTCFconstants["cXmlCollapsedDisabled"] = "true";
    // Set this to collapse (hide) folders/components that are disabled.
    $UCTCFconstants["cXmlCollapsedEnabled"] = "false";
    // Set this to un-collapse (show) folders/components that are enabled.
    //  echo "Hello world.  Attempting to generate .csv files.\n";
    /** Initialize and run various CACF_*() functions to get low level Vault data. **/
    /* Call CACF_Init() to perform all initialization needed for CACF_*() functions. */
    /* Note:  All the parameters are outputs from this function! */
    CACF_Init($db, $CACFconstants, $altiumParmsByComponentLines, $auditComponentsByType, $auditComponentsByTypeUnmatched, $altiumUserNamesByGuid, $altiumAclUserPermissions);
    /** Alter certain constants setup by CACF_Init() **/
    /* Flag that we DO NOT wish to keep 0 length output files that we generate. */
    $CACFconstants["doKeepZeroLengthOutputFiles"] = false;
    /* Flag that we will not generate the per-component audit files. */
    $CACFconstants["auditComponentsFileName"] = "";
    /* Retrieve necessary global constants. */
    $auditFileExt = $CACFconstants["auditFileExt"];
    $auditComponentsByTypeFileName = $CACFconstants["auditComponentsByTypeFileName"];
    /* Strip off the extension from $CmpLibFileName to get a base name. */
    $CmpLibBaseName = preg_replace("/\\.[^.]+/", "", $CmpLibFileName);
    //  echo "CmpLibFileName is \"$CmpLibFileName\".\n";
    //  echo "CmpLibBaseName is \"$CmpLibBaseName\".\n";
    /* Change the $auditComponentsByTypeFileName to remove reference to "_vault_database". */
    $auditComponentsByTypeFileName = preg_replace("/_vault_database/", "", $auditComponentsByTypeFileName);
    /* Change the $auditComponentsByTypeFileName to append the name of our CmpLib basename. */
    $auditComponentsByTypeFileName = preg_replace("/{$auditFileExt}/", "_" . $CmpLibBaseName . $auditFileExt, $auditComponentsByTypeFileName);
    /* Create a version of this with a "_Vault" suffix. */
    $auditComponentsByTypeFileNameVault = preg_replace("/{$auditFileExt}/", "_Vault" . $auditFileExt, $auditComponentsByTypeFileName);
    /* Create a version of this with a "_CmpLib" suffix. */
    $auditComponentsByTypeFileNameCmpLib = preg_replace("/{$auditFileExt}/", "_CmpLib" . $auditFileExt, $auditComponentsByTypeFileName);
    /* Create a version of this with a "_Excel" suffix. */
    $auditComponentsByTypeFileNameExcel = preg_replace("/{$auditFileExt}/", "_Excel" . $auditFileExt, $auditComponentsByTypeFileName);
    /* Store back to CACFconstants */
    $CACFconstants["auditComponentsByTypeFileName"] = $auditComponentsByTypeFileName;
    $CACFconstants["auditComponentsByTypeFileNameVault"] = $auditComponentsByTypeFileNameVault;
    $CACFconstants["auditComponentsByTypeFileNameCmpLib"] = $auditComponentsByTypeFileNameCmpLib;
    $CACFconstants["auditComponentsByTypeFileNameExcel"] = $auditComponentsByTypeFileNameExcel;
    /** Get the GUID of our default Vault. **/
    /* Analyze all Vault Vaults. */
    CACF_AnalyzeVaultVaults($db, $CACFconstants, $altiumVaultsByHrid);
    /* Look up the GUID of our default Vault. */
    $defaultVaultHrid = $UCTCFconstants["defaultVaultHrid"];
    $defaultVaultGuid = $altiumVaultsByHrid[$defaultVaultHrid]["GUID"];
    echo "defaultVaultGuid is \"{$defaultVaultGuid}\"\n";
    $UCTCFconstants["defaultVaultGuid"] = $defaultVaultGuid;
    /** Get the GUID of our default Revision Naming Scheme. **/
    /* Analyze all Vault Revision Naming Schemes. */
    CACF_AnalyzeVaultRevisionNamingSchemes($db, $CACFconstants, $altiumRevisionNamingSchemesByHrid);
    /* Look up the GUID of our default Revision Naming Scheme. */
    $defaultRevisionNamingSchemeHrid = $UCTCFconstants["defaultRevisionNamingSchemeHrid"];
    $defaultRevisionNamingSchemeGuid = $altiumRevisionNamingSchemesByHrid[$defaultRevisionNamingSchemeHrid]["GUID"];
    echo "defaultRevisionNamingSchemeGuid is \"{$defaultRevisionNamingSchemeGuid}\"\n";
    $UCTCFconstants["defaultRevisionNamingSchemeGuid"] = $defaultRevisionNamingSchemeGuid;
    /** Get the GUID of our default LifeCycle Definition. **/
    /* Analyze all Vault LifeCycle Definitions. */
    CACF_AnalyzeVaultLifeCycleDefinitions($db, $CACFconstants, $altiumLifeCycleDefinitionsByHrid);
    /* Look up the GUID of our default LifeCycle Definition. */
    $defaultLifeCycleDefinitionHrid = $UCTCFconstants["defaultLifeCycleDefinitionHrid"];
    $defaultLifeCycleDefinitionGuid = $altiumLifeCycleDefinitionsByHrid[$defaultLifeCycleDefinitionHrid]["GUID"];
    echo "defaultLifeCycleDefinitionGuid is \"{$defaultLifeCycleDefinitionGuid}\"\n";
    $UCTCFconstants["defaultLifeCycleDefinitionGuid"] = $defaultLifeCycleDefinitionGuid;
    /** Retrieve and cache various other information from the Vault database. **/
    /* Analyze all Vault folders and extract all linkages so that we understand folder trees. */
    CACF_AnalyzeVaultFolders($db, $CACFconstants, $altiumFoldersByGuid);
    /* Analyze all Vault items and cache certain fields, indexed by GUID. */
    CACF_AnalyzeVaultItems($db, $CACFconstants, $altiumItemsByGuid);
    /* Analyze all Vault item revisions and cache certain fields, indexed by GUID. */
    CACF_AnalyzeVaultItemRevisions($db, $CACFconstants, $altiumItemRevsByGuid);
    /* Analyze all Vault item user parameters and store for later use. */
    CACF_AnalyzeVaultItemUserParameters($db, $CACFconstants, $altiumUserParmNames, $altiumItemUserParmValuesByGuid);
    /* Cache ACL data for later use. */
    CACF_CreateAclAuditData($db, $CACFconstants, $altiumUserNamesByGuid, $altiumFoldersByGuid, $altiumItemsByGuid, $altiumItemRevsByGuid, $altiumAclUserPermissions, $altiumAclDataByObjectHrid, $altiumAclDataByObjectGuid);
    /* Create model audit data. */
    CACF_CreateModelAuditData($db, $CACFconstants, $altiumUserNamesByGuid, $altiumFoldersByGuid, $altiumAclDataByObjectGuid, $altiumItemRevsByGuid, $altiumModelDataByItemRevHrid);
    /* Create component audit data. */
    CACF_CreateComponentAuditData($db, $CACFconstants, $altiumUserNamesByGuid, $altiumFoldersByGuid, $altiumAclDataByObjectGuid, $altiumItemRevsByGuid, $altiumItemSysParmValuesByGuid, $altiumObsoleteCompsByGuid);
}