-
Notifications
You must be signed in to change notification settings - Fork 242
/
hide.php
97 lines (81 loc) · 2.99 KB
/
hide.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
//
// Created on: <21-Jan-05 16:00:52 kk>
//
// ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
// SOFTWARE NAME: eZ publish
// SOFTWARE RELEASE: 3.8.x
// COPYRIGHT NOTICE: Copyright (C) 1999-2006 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 hide.php
*/
include_once( "kernel/classes/ezcontentobjecttreenode.php" );
include_once( "lib/ezutils/classes/ezini.php" );
$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;
foreach( $rootNodeIDList as $nodeID )
{
$rootNode = eZContentObjectTreeNode::fetch( $nodeID );
while( true )
{
$nodeArray =& $rootNode->subTree( array( 'ClassFilterType' => 'include',
'ClassFilterArray' => $hideClasses,
'Offset' => $offset,
'Limit' => $limit ) );
if ( !$nodeArray ||
count( $nodeArray ) == 0 )
{
break;
}
$offset += $limit;
foreach ( array_keys( $nodeArray ) as $key )
{
$node =& $nodeArray[$key];
$dataMap =& $node->attribute( 'data_map' );
$dateAttributeName = $hideAttributeArray[$node->attribute( 'class_identifier' )];
if ( !$dateAttributeName )
{
continue;
}
$dateAttribute =& $dataMap[$dateAttributeName];
if ( is_null( $dateAttribute ) || !$dateAttribute->hasContent() )
{
continue;
}
$date = $dateAttribute->content();
$retractDate = $date->attribute( 'timestamp' );
if ( $retractDate > 0 && $retractDate < $currrentDate && !$node->attribute( 'is_hidden' ) )
{
eZContentObjectTreeNode::hideSubTree( $node );
if ( !$isQuiet )
{
$cli->output( 'Hiding node : ' . $node->attribute( 'node_id' ) );
}
}
}
}
}
?>