Forums / Developer / Impossible to fetch users using subTreeByNodeID()

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

eZ debug

Timing: Jan 18 2025 02:58:13
Script start
Timing: Jan 18 2025 02:58:13
Module start 'content'
Timing: Jan 18 2025 02:58:13
Module end 'content'
Timing: Jan 18 2025 02:58:14
Script end

Main resources:

Total runtime0.8926 sec
Peak memory usage4,096.0000 KB
Database Queries204

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 589.2734180.8125
Module start 'content' 0.00610.7481 770.0859650.2813
Module end 'content' 0.75420.1384 1,420.3672337.0547
Script end 0.8925  1,757.4219 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.4546210.0002
Check MTime0.00150.1688210.0001
Mysql Total
Database connection0.00070.078210.0007
Mysqli_queries0.799089.51612040.0039
Looping result0.00230.26222020.0000
Template Total0.864496.820.4322
Template load0.00210.232120.0010
Template processing0.862396.605220.4312
Template load and register function0.00010.011810.0001
states
state_id_array0.00090.105110.0009
state_identifier_array0.00070.079320.0004
Override
Cache load0.00180.2060380.0000
Sytem overhead
Fetch class attribute can translate value0.00160.176650.0003
Fetch class attribute name0.00140.161480.0002
XML
Image XML parsing0.00180.206850.0004
class_abstraction
Instantiating content class attribute0.00000.002190.0000
General
dbfile0.00860.9591390.0002
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 27
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs