eZ Publish  [4.0]
unpublish.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Created on: <16-σΕΞ-2003 16:09:52 sp>
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 unpublish.php
00030 */
00031 
00032 //include_once( "kernel/classes/ezcontentobjecttreenode.php" );
00033 
00034 
00035 
00036 // Check for extension
00037 //include_once( 'lib/ezutils/classes/ezextension.php' );
00038 require_once( 'kernel/common/ezincludefunctions.php' );
00039 eZExtension::activateExtensions();
00040 // Extension check end
00041 
00042 //include_once( "lib/ezutils/classes/ezini.php" );
00043 $ini = eZINI::instance( 'content.ini' );
00044 $unpublishClasses = $ini->variable( 'UnpublishSettings','ClassList' );
00045 
00046 $rootNodeIDList = $ini->variable( 'UnpublishSettings','RootNodeList' );
00047 
00048 $currrentDate = time();
00049 
00050 foreach( $rootNodeIDList as $nodeID )
00051 {
00052     $rootNode = eZContentObjectTreeNode::fetch( $nodeID );
00053 
00054     $articleNodeArray = $rootNode->subTree( array( 'ClassFilterType' => 'include',
00055                                                     'ClassFilterArray' => $unpublishClasses ) );
00056 
00057     foreach ( $articleNodeArray as $articleNode )
00058     {
00059         $article = $articleNode->attribute( 'object' );
00060         $dataMap = $article->attribute( 'data_map' );
00061 
00062         $dateAttribute = $dataMap['unpublish_date'];
00063 
00064         if ( is_null( $dateAttribute ) )
00065             continue;
00066 
00067         $date = $dateAttribute->content();
00068         $articleRetractDate = $date->attribute( 'timestamp' );
00069         if ( $articleRetractDate > 0 && $articleRetractDate < $currrentDate )
00070         {
00071             // Clean up content cache
00072             //include_once( 'kernel/classes/ezcontentcachemanager.php' );
00073             eZContentCacheManager::clearContentCacheIfNeeded( $article->attribute( 'id' ) );
00074 
00075             $article->removeThis( $articleNode->attribute( 'node_id' ) );
00076         }
00077     }
00078 }
00079 
00080 
00081 ?>