--- ../ezpublish-3.9.1/bin/php/flatten.php      2007-03-14 16:37:48.000000000 +0100
+++ bin/php/flatten.php 2007-03-19 10:58:13.000000000 +0100
@@ -45,7 +45,7 @@
 
 $script->startup();
 
-$options = $script->getOptions( "[db-user:][db-password:][db-database:][db-type:|db-driver:][sql]",
+$options = $script->getOptions( "[db-user:][db-password:][db-database:][db-type:|db-driver:][sql][archived-content]",
                                 "[name]",
                                 array( 'db-host' => "Database host",
                                        'db-user' => "Database user",
@@ -53,7 +53,8 @@
                                        'db-database' => "Database name",
                                        'db-driver' => "Database driver",
                                        'db-type' => "Database driver, alias for --db-driver",
-                                       'sql' => "Display sql queries"
+                                       'sql' => "Display sql queries",
+                                       'archived-content' => "Remove archived versions of content objects as well",
                                        ) );
 $script->initialize();
 
@@ -70,6 +71,7 @@
 $dbImpl = $options['db-driver'] ? $options['db-driver'] : false;
 $showSQL = $options['sql'] ? true : false;
 $siteAccess = $options['siteaccess'] ? $options['siteaccess'] : false;
+$archivedToo = $options['archived-content'] ? true : false;
 
 if ( $siteAccess )
 {
@@ -160,7 +162,16 @@
 {
     include_once( 'kernel/classes/ezcontentobject.php' );
     $cli->output( "Removing non-published content object versions" );
-    eZContentObjectVersion::removeVersions();
+    $statuses = array( EZ_VERSION_STATUS_DRAFT,
+                       EZ_VERSION_STATUS_PENDING,
+                       EZ_VERSION_STATUS_REJECTED,
+                       EZ_VERSION_STATUS_INTERNAL_DRAFT );
+    if ( $archivedToo )
+    {
+        $statuses[] = EZ_VERSION_STATUS_ARCHIVED;
+    }
+    $count = eZContentObjectVersion::removeVersions( $statuses );
+    $cli->output( "Removed $count versions" );
 }
 
 if ( $flatten['contentclass'] )
