Adding user to a new location

Author Message

Milad P

Tuesday 25 July 2006 6:00:09 am

I found a new problem when upgrading from 3.6.5 to 3.8.1. I try to add a new location for a user with this code which has worked fine with earlier ez versions. I don't get any error messages or anything and it doesn't add the new location.

Any suggestions?

/Milad

        // User exists (either before or has just been created). Need to add the new location for the user

        // 1. Determine the userID of the user.
        // 2. Fetch the user object
        // 3. Do $object->createNodeAssignment($groupNodeID, false); (last parameter = isMainNode)

        // fetch some data into an array of associative arrays
        $userID = $rows[0]["contentobject_id"];
                // echo $userID;
        // Need to unpublish the user to be able to add it to the new location.
        include_once('kernel/classes/ezcontentobject.php');
        $object =& eZContentObject::fetch( $userID );

        $version =& eZContentObjectVersion::fetchVersion(  $object->attribute('current_version'), $userID );
        $version->unpublish();

        // Add the location to the user
        $object->createNodeAssignment($groupID, false);

        // Finally, publish the user again.
        include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
        $operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $userID,
                                                        'version' => $object->attribute('current_version') ) );


Kristof Coomans

Tuesday 25 July 2006 9:50:49 am

Hi Milad

Take a look at http://pubsvn.ez.no/wiki/en/ez/adding_additional_locations_for_an_object. The code mentioned there comes right out of the kernel of eZ 3.8.

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 18 2025 15:51:16
Script start
Timing: Jan 18 2025 15:51:16
Module start 'layout'
Timing: Jan 18 2025 15:51:16
Module start 'content'
Timing: Jan 18 2025 15:51:17
Module end 'content'
Timing: Jan 18 2025 15:51:17
Script end

Main resources:

Total runtime0.8339 sec
Peak memory usage4,096.0000 KB
Database Queries54

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 589.3438152.6250
Module start 'layout' 0.00540.0033 741.968839.4453
Module start 'content' 0.00870.8238 781.4141522.7656
Module end 'content' 0.83240.0014 1,304.17978.1641
Script end 0.8339  1,312.3438 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.3775160.0002
Check MTime0.00140.1629160.0001
Mysql Total
Database connection0.00090.108010.0009
Mysqli_queries0.791694.9278540.0147
Looping result0.00050.0642520.0000
Template Total0.797995.720.3990
Template load0.00170.200620.0008
Template processing0.796395.485920.3981
Template load and register function0.00010.016610.0001
states
state_id_array0.00160.194010.0016
state_identifier_array0.00120.146120.0006
Override
Cache load0.00130.1532110.0001
Sytem overhead
Fetch class attribute can translate value0.00110.135120.0006
Fetch class attribute name0.00130.151630.0004
XML
Image XML parsing0.00070.080220.0003
class_abstraction
Instantiating content class attribute0.00000.001130.0000
General
dbfile0.00080.0919160.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
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
2content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 8
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs