eZ Publish  [4.0]
ezcontentclassoperations.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Definition of eZContentClassOperations class
00004 //
00005 // Created on: <23-Jan-2006 13:25:46 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 ezcontentclassoperations.php
00032 */
00033 
00034 /*!
00035   \class eZContentClassOperations ezcontentclassoperations.php
00036   \brief The class eZContentClassOperations is a place where
00037          content class operations are encapsulated.
00038   We move them out from eZContentClass because they may content code
00039   which is not directly related to content classes (e.g. clearing caches, etc).
00040 */
00041 
00042 //include_once( 'kernel/classes/ezcontentclass.php' );
00043 
00044 class eZContentClassOperations
00045 {
00046     /*!
00047      Removes content class and all data associated with it.
00048      \static
00049     */
00050     static function remove( $classID )
00051     {
00052         $contentClass = eZContentClass::fetch( $classID );
00053 
00054         if ( $contentClass == null or !$contentClass->isRemovable() )
00055             return false;
00056 
00057         // Remove all objects
00058         $contentObjects = eZContentObject::fetchSameClassList( $classID );
00059         //include_once( 'kernel/classes/ezcontentobjectoperations.php' );
00060         foreach ( $contentObjects as $contentObject )
00061         {
00062             eZContentObjectOperations::remove( $contentObject->attribute( 'id' ) );
00063         }
00064 
00065         if ( count( $contentObjects ) == 0 )
00066             eZContentObject::expireAllViewCache();
00067 
00068         eZContentClassClassGroup::removeClassMembers( $classID, 0 );
00069         eZContentClassClassGroup::removeClassMembers( $classID, 1 );
00070 
00071         // Fetch real version and remove it
00072         $contentClass->remove( true );
00073 
00074         // Fetch temp version and remove it
00075         $tempDeleteClass = eZContentClass::fetch( $classID, true, 1 );
00076         if ( $tempDeleteClass != null )
00077             $tempDeleteClass->remove( true, 1 );
00078 
00079         return true;
00080     }
00081 }
00082 
00083 
00084 ?>