[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/cronjobs/ -> old_drafts_cleanup.php (source)

   1  <?php
   2  //
   3  // Created on: <23-Aug-2006 11:00:00 amos>
   4  //
   5  // SOFTWARE NAME: eZ publish
   6  // SOFTWARE RELEASE: 3.9.0
   7  // BUILD VERSION: 17785
   8  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
   9  // SOFTWARE LICENSE: GNU General Public License v2.0
  10  // NOTICE: >
  11  //   This program is free software; you can redistribute it and/or
  12  //   modify it under the terms of version 2.0  of the GNU General
  13  //   Public License as published by the Free Software Foundation.
  14  //
  15  //   This program is distributed in the hope that it will be useful,
  16  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  17  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18  //   GNU General Public License for more details.
  19  //
  20  //   You should have received a copy of version 2.0 of the GNU General
  21  //   Public License along with this program; if not, write to the Free
  22  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  23  //   MA 02110-1301, USA.
  24  //
  25  //
  26  
  27  /*! \file remove_old_drafts.php
  28  */
  29  
  30  
  31  include_once ( 'lib/ezutils/classes/ezini.php' );
  32  include_once ( 'kernel/classes/ezcontentobjectversion.php' );
  33  
  34  if ( !$isQuiet )
  35      $cli->output( "Cleaning up user's drafts..." );
  36  
  37  // Cleaning up usual drafts
  38  $ini =& eZINI::instance( 'content.ini' );
  39  $draftsCleanUpLimit = $ini->hasVariable( 'VersionManagement', 'DraftsCleanUpLimit' ) ?
  40                           $ini->variable( 'VersionManagement', 'DraftsCleanUpLimit' ) : 0;
  41  $durationSetting = $ini->hasVariable( 'VersionManagement', 'DraftsDuration' ) ?
  42                        $ini->variable( 'VersionManagement', 'DraftsDuration' ) : array( 'days' => 90 );
  43  
  44  $isDurationSet = false;
  45  $duration = 0;
  46  if ( is_array( $durationSetting ) )
  47  {
  48      if ( isset( $durationSetting[ 'days' ] ) and is_numeric( $durationSetting[ 'days' ] ) )
  49      {
  50          $duration += $durationSetting[ 'days' ] * 60 * 60 * 24;
  51          $isDurationSet = true;
  52      }
  53      if ( isset( $durationSetting[ 'hours' ] ) and is_numeric( $durationSetting[ 'hours' ] ) )
  54      {
  55          $duration += $durationSetting[ 'hours' ] * 60 * 60;
  56          $isDurationSet = true;
  57      }
  58      if ( isset( $durationSetting[ 'minutes' ] ) and is_numeric( $durationSetting[ 'minutes' ] ) )
  59      {
  60          $duration += $durationSetting[ 'minutes' ] * 60;
  61          $isDurationSet = true;
  62      }
  63      if ( isset( $durationSetting[ 'seconds' ] ) and is_numeric( $durationSetting[ 'seconds' ] ) )
  64      {
  65          $duration += $durationSetting[ 'seconds' ];
  66          $isDurationSet = true;
  67      }
  68  }
  69  
  70  if ( $isDurationSet )
  71  {
  72      $expiryTime = mktime() - $duration;
  73      $processedCount = eZContentObjectVersion::removeVersions( EZ_VERSION_STATUS_DRAFT, $draftsCleanUpLimit, $expiryTime );
  74  
  75      if ( !$isQuiet )
  76          $cli->output( "Cleaned up " . $processedCount . " drafts" );
  77  }
  78  else
  79  {
  80      if ( !$isQuiet )
  81          $cli->output( "Lifetime is not set for user's drafts (see your ini-settings, content.ini, VersionManagement section)." );
  82  }
  83  
  84  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7