|
eZ Publish
[4.1]
|
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.1.x 00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2009 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 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 class eZContentObjectOperations 00043 { 00044 /*! 00045 Removes content object and all data associated with it. 00046 \static 00047 */ 00048 static function remove( $objectID, $removeSubtrees = true ) 00049 { 00050 eZContentCacheManager::clearContentCacheIfNeeded( $objectID ); 00051 00052 $object = eZContentObject::fetch( $objectID ); 00053 if ( !is_object( $object ) ) 00054 return false; 00055 00056 // TODO: Is content cache cleared for all objects in subtree ?? 00057 00058 if ( $removeSubtrees ) 00059 { 00060 $assignedNodes = $object->attribute( 'assigned_nodes' ); 00061 if ( count( $assignedNodes ) == 0 ) 00062 { 00063 $object->purge(); 00064 eZContentObject::expireAllViewCache(); 00065 return true; 00066 } 00067 $assignedNodeIDArray = array(); 00068 foreach( $assignedNodes as $node ) 00069 { 00070 $assignedNodeIDArray[] = $node->attribute( 'node_id' ); 00071 } 00072 eZContentObjectTreeNode::removeSubtrees( $assignedNodeIDArray, false ); 00073 } 00074 else 00075 $object->purge(); 00076 00077 return true; 00078 } 00079 } 00080 00081 00082 ?>