Adding a location programmatically with php

Author Message

Brian Gerspacher

Monday 21 November 2005 7:45:56 am

I'm looking to add a user that exists in a existing user group (say, Guest accounts) to a newly created group, but I would like them to remain a member of the Guest accounts group.

So far in the forums I have found reference to eZContentObjectTreeNodeOperations::move(), which moves an item to a new location without retaining the old one. Unfortunately, eZContentObjectTreeNodeOperations doesn't offer a similar method to add alocation.

I have worked with some code which (I think) is executed when you add a location in the admin site [ kernel/content/action.php - around line 630 - $module->isCurrentAction( 'AddAssignment' ) ]. I've picked out what seems to be the appropriate code...

$userVersion =& user->createNewVersion(false, true);
$nodeAssignment =& $userVersion->assignToNode($myGroup->attribute('main_node_id'), false);
eZOperationHandler::execute('content', 'publish', array('object_id', => $user->attribute('id'), 'version' => $userVersion->attribute('version')));

...but I can't seem to get the final result I'm looking for. Any thoughts?

Thanks,

Brian.

Kristof Coomans

Monday 21 November 2005 10:56:06 am

Maybe this will help you: http://ez.no/community/forum/developer/adding_location

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

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 19 2025 07:15:34
Script start
Timing: Jan 19 2025 07:15:34
Module start 'layout'
Timing: Jan 19 2025 07:15:34
Module start 'content'
Timing: Jan 19 2025 07:15:34
Module end 'content'
Timing: Jan 19 2025 07:15:34
Script end

Main resources:

Total runtime0.0185 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0052 590.4219152.6406
Module start 'layout' 0.00520.0042 743.062539.4766
Module start 'content' 0.00940.0067 782.539189.3984
Module end 'content' 0.01610.0023 871.937530.3047
Script end 0.0184  902.2422 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002714.6424140.0002
Check MTime0.00126.2352140.0001
Mysql Total
Database connection0.00073.641910.0007
Mysqli_queries0.003619.236330.0012
Looping result0.00000.140410.0000
Template Total0.00189.710.0018
Template load0.00095.042310.0009
Template processing0.00094.657110.0009
Override
Cache load0.00063.437110.0006
General
dbfile0.001910.060080.0002
String conversion0.00000.059340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs