function execute( $process, $event )
    {
        $parameters = $process->attribute( 'parameter_list' );
        
        $oldNodeID = $parameters['node_id'];
        $newNodeID = $parameters['selected_node_id'];
        
        // Fetch blocks which require node_id update
        $oldNodeBlocks = eZFlowBlock::fetchObjectList( eZFlowBlock::definition(), null, array( 'node_id' => $oldNodeID ) );
        $newNodeBlocks = eZFlowBlock::fetchObjectList( eZFlowBlock::definition(), null, array( 'node_id' => $newNodeID ) );
        
        // Loop over fetched blocks for old node and update node_id with new value
        foreach( $oldNodeBlocks as $oldNodeBlock )
        {
            $oldNodeBlock->setAttribute( 'node_id', $newNodeID );
            $oldNodeBlock->store();
        }

        // Loop over fetched blocks for new node and update node_id with new value
        foreach( $newNodeBlocks as $newNodeBlock )
        {
            $newNodeBlock->setAttribute( 'node_id', $oldNodeID );
            $newNodeBlock->store();
        }
        
        return eZWorkflowType::STATUS_ACCEPTED;
    }
Ejemplo n.º 2
0
//
//  You should have received a copy of version 2.0 of the GNU General
//  Public License along with this program; if not, write to the Free
//  Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//  MA 02110-1301, USA.
// ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
//

define( 'ROTATION_NONE', 0 );
define( 'ROTATION_SIMPLE', 1 );
define( 'ROTATION_RANDOM', 2 );

$db = eZDB::instance();
$ini = eZINI::instance( 'block.ini' );

$blockTableDef = eZFlowBlock::definition();
$poolTableDef = eZFlowPoolItem::definition();
$blockTMPTable = $db->generateUniqueTempTableName( 'ezm_block_tmp_%' );
$poolTMPTable = $db->generateUniqueTempTableName( 'ezm_pool_tmp_%' );

$nodeID = 2;
$time = time() - 5;

if( isset( $Params['NodeID'] ) )
    $nodeID = (int)$Params['NodeID'];
if( isset( $Params['Time'] ) )
    $time = (int)$Params['Time'];

$db->createTempTable( 'CREATE TEMPORARY TABLE ' . $blockTMPTable .
                        ' AS SELECT * FROM ' . $blockTableDef['name'] .
                            ' WHERE node_id=\'' . $nodeID . '\'' );