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.