Exemplo n.º 1
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 . '\'' );
    /**
     * Method executed when an object copy is created 
     * by using the clone keyword
     *
     */
    public function __clone()
    {
        $oldBlockID = $this->attributes['id'];

        $this->attributes['id'] = md5( (string)microtime() . (string)mt_rand() );
        $this->attributes['action'] = 'add';

        $oldItems = eZPersistentObject::fetchObjectList( eZFlowPoolItem::definition(), null, array( 'block_id' => $oldBlockID ) );

        foreach ( $oldItems as $oldItem )
        {
            $attrs = array(
                'object_id' => $oldItem->attribute( 'object_id' ),
                'node_id' => $oldItem->attribute( 'node_id' ),
                'priority' => $oldItem->attribute( 'priority' ),
                'ts_publication' => $oldItem->attribute( 'ts_publication' ),
                'action' => 'add'
            );
            $newPageBlockItem = new eZPageBlockItem( $attrs );
            $this->addItem( $newPageBlockItem );
        }
    }