|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Definition of eZContentObjectOperations class 00004 // 00005 // Created on: <23-Jan-2006 14:38:57 vs> 00006 // 00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00008 // SOFTWARE NAME: eZ Publish 00009 // SOFTWARE RELEASE: 4.0.x 00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS 00011 // SOFTWARE LICENSE: GNU General Public License v2.0 00012 // NOTICE: > 00013 // This program is free software; you can redistribute it and/or 00014 // modify it under the terms of version 2.0 of the GNU General 00015 // Public License as published by the Free Software Foundation. 00016 // 00017 // This program is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 // GNU General Public License for more details. 00021 // 00022 // You should have received a copy of version 2.0 of the GNU General 00023 // Public License along with this program; if not, write to the Free 00024 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 00025 // MA 02110-1301, USA. 00026 // 00027 // 00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## 00029 // 00030 00031 /*! \file ezcontentobjectoperations.php 00032 */ 00033 00034 /*! 00035 \class eZContentObjectOperations ezcontentobjectoperations.php 00036 \brief The class eZContentObjectOperations is a place where 00037 content object operations are encapsulated. 00038 We move them out from eZContentObject because they may content code 00039 which is not directly related to content objects (e.g. clearing caches, etc). 00040 */ 00041 00042 //include_once( 'kernel/classes/ezcontentobject.php' ); 00043 00044 class eZContentObjectOperations 00045 { 00046 /*! 00047 Removes content object and all data associated with it. 00048 \static 00049 */ 00050 static function remove( $objectID, $removeSubtrees = true ) 00051 { 00052 //include_once( 'kernel/classes/ezcontentcachemanager.php' ); 00053 eZContentCacheManager::clearContentCacheIfNeeded( $objectID ); 00054 00055 $object = eZContentObject::fetch( $objectID ); 00056 if ( !is_object( $object ) ) 00057 return false; 00058 00059 // TODO: Is content cache cleared for all objects in subtree ?? 00060 00061 if ( $removeSubtrees ) 00062 { 00063 $assignedNodes = $object->attribute( 'assigned_nodes' ); 00064 if ( count( $assignedNodes ) == 0 ) 00065 { 00066 $object->purge(); 00067 eZContentObject::expireAllViewCache(); 00068 return true; 00069 } 00070 $assignedNodeIDArray = array(); 00071 foreach( $assignedNodes as $node ) 00072 { 00073 $assignedNodeIDArray[] = $node->attribute( 'node_id' ); 00074 } 00075 eZContentObjectTreeNode::removeSubtrees( $assignedNodeIDArray, false ); 00076 } 00077 else 00078 $object->purge(); 00079 00080 return true; 00081 } 00082 } 00083 00084 00085 ?>