|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Created on: <23-Aug-2006 11:00:00 amos> 00004 // 00005 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00006 // SOFTWARE NAME: eZ Publish 00007 // SOFTWARE RELEASE: 4.0.x 00008 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS 00009 // SOFTWARE LICENSE: GNU General Public License v2.0 00010 // NOTICE: > 00011 // This program is free software; you can redistribute it and/or 00012 // modify it under the terms of version 2.0 of the GNU General 00013 // Public License as published by the Free Software Foundation. 00014 // 00015 // This program is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU General Public License for more details. 00019 // 00020 // You should have received a copy of version 2.0 of the GNU General 00021 // Public License along with this program; if not, write to the Free 00022 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00023 // MA 02110-1301, USA. 00024 // 00025 // 00026 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00027 // 00028 00029 /*! \file remove_old_drafts.php 00030 */ 00031 00032 00033 //include_once( 'lib/ezutils/classes/ezini.php' ); 00034 //include_once( 'kernel/classes/ezcontentobjectversion.php' ); 00035 00036 if ( !$isQuiet ) 00037 $cli->output( "Cleaning up user's drafts..." ); 00038 00039 // Cleaning up usual drafts 00040 $ini = eZINI::instance( 'content.ini' ); 00041 $draftsCleanUpLimit = $ini->hasVariable( 'VersionManagement', 'DraftsCleanUpLimit' ) ? 00042 $ini->variable( 'VersionManagement', 'DraftsCleanUpLimit' ) : 0; 00043 $durationSetting = $ini->hasVariable( 'VersionManagement', 'DraftsDuration' ) ? 00044 $ini->variable( 'VersionManagement', 'DraftsDuration' ) : array( 'days' => 90 ); 00045 00046 $isDurationSet = false; 00047 $duration = 0; 00048 if ( is_array( $durationSetting ) ) 00049 { 00050 if ( isset( $durationSetting[ 'days' ] ) and is_numeric( $durationSetting[ 'days' ] ) ) 00051 { 00052 $duration += $durationSetting[ 'days' ] * 60 * 60 * 24; 00053 $isDurationSet = true; 00054 } 00055 if ( isset( $durationSetting[ 'hours' ] ) and is_numeric( $durationSetting[ 'hours' ] ) ) 00056 { 00057 $duration += $durationSetting[ 'hours' ] * 60 * 60; 00058 $isDurationSet = true; 00059 } 00060 if ( isset( $durationSetting[ 'minutes' ] ) and is_numeric( $durationSetting[ 'minutes' ] ) ) 00061 { 00062 $duration += $durationSetting[ 'minutes' ] * 60; 00063 $isDurationSet = true; 00064 } 00065 if ( isset( $durationSetting[ 'seconds' ] ) and is_numeric( $durationSetting[ 'seconds' ] ) ) 00066 { 00067 $duration += $durationSetting[ 'seconds' ]; 00068 $isDurationSet = true; 00069 } 00070 } 00071 00072 if ( $isDurationSet ) 00073 { 00074 $expiryTime = time() - $duration; 00075 $processedCount = eZContentObjectVersion::removeVersions( eZContentObjectVersion::STATUS_DRAFT, $draftsCleanUpLimit, $expiryTime ); 00076 00077 if ( !$isQuiet ) 00078 $cli->output( "Cleaned up " . $processedCount . " drafts" ); 00079 } 00080 else 00081 { 00082 if ( !$isQuiet ) 00083 $cli->output( "Lifetime is not set for user's drafts (see your ini-settings, content.ini, VersionManagement section)." ); 00084 } 00085 00086 ?>