Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Implemented enhancement #014831: hide cronjob is totally useless fo…
…r big sites Slightly modified version of Georg Franz's contribution.
- Loading branch information
Bertrand Dunogier
committed
Aug 4, 2010
1 parent
62f95e7
commit 24210d2
Showing
2 changed files
with
59 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,85 @@ | ||
<?php | ||
// | ||
// Created on: <21-Jan-05 16:00:52 kk> | ||
// | ||
// ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ## | ||
// SOFTWARE NAME: eZ Publish | ||
// SOFTWARE RELEASE: 4.1.x | ||
// COPYRIGHT NOTICE: Copyright (C) 1999-2010 eZ Systems AS | ||
// SOFTWARE LICENSE: GNU General Public License v2.0 | ||
// NOTICE: > | ||
// This program is free software; you can redistribute it and/or | ||
// modify it under the terms of version 2.0 of the GNU General | ||
// Public License as published by the Free Software Foundation. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// 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 ## | ||
// | ||
|
||
/*! \file | ||
*/ | ||
/** | ||
* File containing the hide.php cronjob. | ||
* | ||
* @copyright Copyright (C) 1999-2010 eZ Systems AS. All rights reserved. | ||
* @license http://ez.no/licenses/gnu_gpl GNU GPL v2 | ||
* @version //autogentag// | ||
* @package kernel | ||
*/ | ||
|
||
$ini = eZINI::instance( 'content.ini' ); | ||
$rootNodeIDList = $ini->variable( 'HideSettings','RootNodeList' ); | ||
$hideAttributeArray = $ini->variable( 'HideSettings', 'HideDateAttributeList' ); | ||
$hideClasses = array_keys( $hideAttributeArray ); | ||
|
||
$currrentDate = time(); | ||
|
||
$offset = 0; | ||
$limit = 20; | ||
$limit = 50; | ||
|
||
$hiddenNodesParams = array( | ||
'LoadDataMap' => false, | ||
'Limit' => $limit, | ||
'Offset' => $offset, | ||
'SortBy' => array( array( 'published', true ) ) ); | ||
|
||
$newMemoryUsage = $oldMemoryUsage = 0; | ||
foreach( $rootNodeIDList as $nodeID ) | ||
{ | ||
$rootNode = eZContentObjectTreeNode::fetch( $nodeID ); | ||
|
||
while( true ) | ||
if ( !$isQuiet ) | ||
{ | ||
$nodeArray = $rootNode->subTree( array( 'ClassFilterType' => 'include', | ||
'ClassFilterArray' => $hideClasses, | ||
'Offset' => $offset, | ||
'Limit' => $limit ) ); | ||
if ( !$nodeArray || | ||
count( $nodeArray ) == 0 ) | ||
{ | ||
break; | ||
} | ||
|
||
$offset += $limit; | ||
$cli->output( 'Hiding content of node "' . $rootNode->attribute( 'name' ) . '" (' . $nodeID . ')' ); | ||
$cli->output(); | ||
} | ||
foreach ( $hideAttributeArray as $hideClass => $attributeIdentifier ) | ||
{ | ||
$offset = 0; | ||
$counter = 0; | ||
$countParams = array( 'ClassFilterType' => 'include', | ||
'ClassFilterArray' => array( $hideClass ), | ||
'Limitation' => array(), | ||
'IgnoreVisibility' => false, | ||
'AttributeFilter' => array( 'and', | ||
array( "{$hideClass}/{$attributeIdentifier}", '<=', $currrentDate ), | ||
array( "{$hideClass}/$attributeIdentifier", '>', 0 ) ) ); | ||
|
||
foreach ( $nodeArray as $node ) | ||
$nodeArrayCount = $rootNode->subTreeCount( $countParams ); | ||
if ( $nodeArrayCount > 0 ) | ||
{ | ||
$dataMap = $node->attribute( 'data_map' ); | ||
|
||
$dateAttributeName = $hideAttributeArray[$node->attribute( 'class_identifier' )]; | ||
|
||
if ( !$dateAttributeName ) | ||
if ( !$isQuiet ) | ||
{ | ||
continue; | ||
$cli->output( "Hiding {$nodeArrayCount} node(s) of class {$hideClass}." ); | ||
} | ||
|
||
$dateAttribute = $dataMap[$dateAttributeName]; | ||
|
||
if ( $dateAttribute === null || !$dateAttribute->hasContent() ) | ||
do | ||
{ | ||
continue; | ||
} | ||
$nodeArray = $rootNode->subTree( $hiddenNodesParams ); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
$date = $dateAttribute->content(); | ||
$retractDate = $date->attribute( 'timestamp' ); | ||
if ( $retractDate > 0 && $retractDate < $currrentDate && !$node->attribute( 'is_hidden' ) ) | ||
{ | ||
eZContentObjectTreeNode::hideSubTree( $node ); | ||
if ( !$isQuiet ) | ||
foreach ( $nodeArray as $node ) | ||
{ | ||
$cli->output( 'Hiding node : ' . $node->attribute( 'node_id' ) ); | ||
eZContentObjectTreeNode::hideSubTree( $node ); | ||
if ( !$isQuiet ) | ||
{ | ||
$cli->output( 'Hiding node: "' . $node->attribute( 'name' ) . '" (' . $node->attribute( 'node_id' ) . ')' ); | ||
} | ||
} | ||
$counter += $limit; | ||
|
||
// clear memory after every batch | ||
eZContentObject::clearCache(); | ||
} while( is_array( $nodeArray ) and count( $nodeArray ) > 0 ); | ||
|
||
if ( !$isQuiet ) | ||
{ | ||
$cli->output(); | ||
} | ||
} | ||
} | ||
if ( !$isQuiet ) | ||
{ | ||
$cli->output(); | ||
} | ||
} | ||
|
||
|
||
?> | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BD: This fetch ignores the class/attribute filtering, and fetches all nodes of the subtree. If you run this on node 2 it hides your entire content tree.