00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 class eZContentObjectTreeNodeOperations
00045 {
00046
00047
00048
00049 function eZContentObjectTreeNodeOperations()
00050 {
00051 }
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 function move( $nodeID, $newParentNodeID )
00069 {
00070 $result = false;
00071
00072 if ( !is_numeric( $nodeID ) || !is_numeric( $newParentNodeID ) )
00073 return false;
00074
00075 include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
00076
00077 $node = eZContentObjectTreeNode::fetch( $nodeID );
00078 if ( !$node )
00079 return false;
00080
00081 $object =& $node->object();
00082 if ( !$object )
00083 return false;
00084
00085 $objectID = $object->attribute( 'id' );
00086 $oldParentNode =& $node->fetchParent();
00087 $oldParentObject =& $oldParentNode->object();
00088
00089
00090 include_once( "lib/ezutils/classes/ezini.php" );
00091 $ini =& eZINI::instance();
00092 $userClassID = $ini->variable( "UserSettings", "UserClassID" );
00093 if ( $object->attribute( 'contentclass_id' ) == $userClassID )
00094 {
00095 include_once( 'kernel/classes/datatypes/ezuser/ezuser.php' );
00096 eZUser::cleanupCache();
00097 }
00098
00099
00100 include_once( 'kernel/classes/ezcontentcachemanager.php' );
00101 eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
00102
00103 include_once( "lib/ezdb/classes/ezdb.php" );
00104 $db =& eZDB::instance();
00105 $db->begin();
00106
00107 $node->move( $newParentNodeID );
00108
00109 $newNode = eZContentObjectTreeNode::fetchNode( $objectID, $newParentNodeID );
00110
00111 if ( $newNode )
00112 {
00113 $newNode->updateSubTreePath();
00114 if ( $newNode->attribute( 'main_node_id' ) == $newNode->attribute( 'node_id' ) )
00115 {
00116
00117 $newParentNode =& $newNode->fetchParent();
00118 $newParentObject =& $newParentNode->object();
00119 if ( $object->attribute( 'section_id' ) != $newParentObject->attribute( 'section_id' ) )
00120 {
00121
00122 eZContentObjectTreeNode::assignSectionToSubTree( $newNode->attribute( 'main_node_id' ),
00123 $newParentObject->attribute( 'section_id' ),
00124 $oldParentObject->attribute( 'section_id' ) );
00125 }
00126 }
00127
00128
00129 include_once( "kernel/classes/eznodeassignment.php" );
00130 $curVersion =& $object->attribute( 'current_version' );
00131 $nodeAssignment = eZNodeAssignment::fetch( $objectID, $curVersion, $oldParentNode->attribute( 'node_id' ) );
00132
00133 if ( $nodeAssignment )
00134 {
00135 $nodeAssignment->setAttribute( 'parent_node', $newParentNodeID );
00136 $nodeAssignment->setAttribute( 'op_code', EZ_NODE_ASSIGNMENT_OP_CODE_MOVE );
00137 $nodeAssignment->store();
00138 }
00139
00140 $result = true;
00141 }
00142
00143 $db->commit();
00144
00145
00146 eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
00147
00148 return $result;
00149 }
00150 }
00151
00152
00153 ?>