diff --git a/sbin/installFriendManager.pl b/sbin/installFriendManager.pl index d8c880b93..7fe2c77ac 100644 --- a/sbin/installFriendManager.pl +++ b/sbin/installFriendManager.pl @@ -89,15 +89,65 @@ sub finish { my $session = shift; ## If your script is adding or changing content you need these lines, otherwise leave them commented - # - # my $versionTag = WebGUI::VersionTag->getWorking($session); - # $versionTag->commit; + updateTemplates($session); + my $versionTag = WebGUI::VersionTag->getWorking($session); + $versionTag->commit; ## $session->var->end; $session->close; } +#------------------------------------------------- +sub updateTemplates { + my $session = shift; + my $packageDir = "packages"; + return undef unless (-d $packageDir); + print "\tUpdating packages.\n"; + opendir(DIR,$packageDir); + my @files = readdir(DIR); + closedir(DIR); + my $newFolder = undef; + foreach my $file (@files) { + next unless ($file =~ /\.wgpkg$/); + # Fix the filename to include a path + $file = $packageDir . "/" . $file; + addPackage( $session, $file ); + } +} + +sub addPackage { + my $session = shift; + my $file = shift; + + # Make a storage location for the package + my $storage = WebGUI::Storage->createTemp( $session ); + $storage->addFileFromFilesystem( $file ); + + # Import the package into the import node + my $package = WebGUI::Asset->getImportNode($session)->importPackage( $storage ); + + # Make the package not a package anymore + $package->update({ isPackage => 0 }); + + # Set the default flag for templates added + my $assetIds + = $package->getLineage( ['self','descendants'], { + includeOnlyClasses => [ 'WebGUI::Asset::Template' ], + } ); + for my $assetId ( @{ $assetIds } ) { + my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); + if ( !$asset ) { + print "Couldn't instantiate asset with ID '$assetId'. Please check package '$file' for corruption.\n"; + next; + } + $asset->update( { isDefault => 1 } ); + } + + return; +} + + __END__ diff --git a/sbin/packages/root_import_account_friendmanager.wgpkg b/sbin/packages/root_import_account_friendmanager.wgpkg index 7e2e57a43..3ae43b1ab 100644 Binary files a/sbin/packages/root_import_account_friendmanager.wgpkg and b/sbin/packages/root_import_account_friendmanager.wgpkg differ