Impossible to fetch users using subTreeByNodeID()

Author Message

Damien MARTIN

Tuesday 16 June 2009 5:44:30 am

Hi there,

I have a problem with eZContentObjectTreeNode::subTreeByNodeID :

I want to fetch all users in a UserGroup to modify them.
I tried to build a cronjob at first, then a simply php code in /bin/php and now within an extension.

It is the same code in all of the tests :

$nodes = eZContentObjectTreeNode::subTreeByNodeID( false, 168 );

<b>168</b> is the NodeId of my UserGroup.

When I try to watch what was returned using <i>print_r</i>, I have an empty array...

The most enervous thing is that it works on another server (who was installed and configured by an other company than mine).

Does anybody have a suggestion about why it returns an empty array ?

Frédéric DAVID

Tuesday 16 June 2009 6:04:54 am

When you execute a cronjob , you are loggin in Anonymous. This user can't read the user section. To resolve your problem, you are two possibilities :

- You can use the parameter "Limitation" in the method subTreeByNodeID to avoid this problem
- You can logg in as an another user, like the admin User.

Blog : http://www.frefred.fr/blog/ez-publish
feZ Meta Data : http://projects.ez.no/fezmetadata

Damien MARTIN

Tuesday 16 June 2009 6:21:36 am

It looks like I'm tired...

On the other site I added a section limitation to access to the user list.
So the 'login step' was transparent for me...

It's logical and I'm asking to myself why I don't tried this before !

Thank you very much Frédéric

I feel like an idiot ^_^

OK : The probleme is solved

Heiner Wurbs

Thursday 11 February 2010 1:04:48 am

Before you fetch in yyour cronjob php file, do sth like this (instead of admin a cronjob user would be better, of course):

$user = eZUser::fetchByName('admin');
$userID = $user->attribute( 'contentobject_id' );
eZUser::setCurrentlyLoggedInUser( $user, $userID );

Now you can fetch the user objects in the User Tab:

$node =& eZContentObjectTreeNode::fetch( 5);

$nodes = $node->subTree( array ('ClassFilterType' => 'include', 'ClassFilterArray' => array ( 4 ))  );

Andy Caiger

Monday 28 June 2010 6:38:13 am

Is there a way to achieve this in template language alone? I'm trying to modify the standard notification behaviour by overriding the template in design/standard/templates/notification/handler/ezsubtree/view and need to fetch the siblings of the object being notified.

I don't really want to write PHP.

Is there a simple and secure way to run the standard notification cronjob with appropriate limitations?

EAB - Integrated Internet Success
Offices in England, France & China.
http://www.eab.co.uk http://www.eab-china.com http://www.eab-france.com

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 05:10:32
Script start
Timing: Jan 18 2025 05:10:32
Module start 'layout'
Timing: Jan 18 2025 05:10:32
Module start 'content'
Timing: Jan 18 2025 05:10:32
Module end 'content'
Timing: Jan 18 2025 05:10:32
Script end

Main resources:

Total runtime0.8706 sec
Peak memory usage4,096.0000 KB
Database Queries67

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 588.0469152.6406
Module start 'layout' 0.00680.0037 740.687539.4766
Module start 'content' 0.01050.8586 780.1641645.1875
Module end 'content' 0.86910.0015 1,425.351616.1250
Script end 0.8705  1,441.4766 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3721160.0002
Check MTime0.00130.1503160.0001
Mysql Total
Database connection0.00140.163910.0014
Mysqli_queries0.798491.7062670.0119
Looping result0.00080.0919650.0000
Template Total0.836496.120.4182
Template load0.00190.217920.0009
Template processing0.834595.852720.4172
Template load and register function0.00010.010510.0001
states
state_id_array0.00140.156910.0014
state_identifier_array0.00100.119420.0005
Override
Cache load0.00160.1864380.0000
Sytem overhead
Fetch class attribute can translate value0.00090.101440.0002
Fetch class attribute name0.00460.524880.0006
XML
Image XML parsing0.00210.243040.0005
class_abstraction
Instantiating content class attribute0.00000.001990.0000
General
dbfile0.00140.1577280.0000
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 27
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs