Populate User Object

Populate User Object

Tuesday 29 August 2006 9:58:16 pm - 3 replies

Modified on Tuesday 29 August 2006 10:53:03 pm by Rob Pratt

Author Message

Kristof Coomans

Wednesday 30 August 2006 3:05:18 am

Hello Rob

Do you call the publish operation after <i>// Publish object and do some other stuff ...</i>?

Take a look at these topics:
http://ez.no/community/forum/setup_design/nodeassignment_and_treenode
http://ez.no/community/forum/developer/insert_objects_from_module_clear_cache_problem
http://ez.no/community/forum/general/publish_object_with_php
http://ez.no/community/forum/developer/importing_data

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

Rob Pratt

Wednesday 30 August 2006 11:41:42 am

Hello.

Thanks for the info you sent. I reviewed the threads you referenced, and I'll try a few different things based on what I saw there. However, I don't think the problem is in the publish step (though I could be wrong). Here's the above code including the code I use to publish the object:


// Create and instantiate user object

// Then ...

$contentObjectAttributes = & $contentObject->contentObjectAttributes();

$contentObjectAttributes[0]->setAttribute('data_int', $attribute1);
$contentObjectAttributes[0]->store();

$contentObjectAttributes[1]->setAttribute('data_int', $attribute2);
$contentObjectAttributes[1]->store();

$userAccountObject = eZUser::fetch($contentObjectAttributes[2]->ContentObjectID);
$userAccountObject->setInformation($contentObject->attribute('id' ), $username, $email, $password, $confirmPassword);
$userAccountObject->store();

$contentObject->setAttribute('status', EZ_VERSION_STATUS_DRAFT);
$contentObject->store();


// Publish it
include_once ('lib/ezutils/classes/ezoperationhandler.php');
$operationResult = eZOperationHandler :: execute('content', 'publish', array (
	'object_id' => $contentObject->attribute('id' ),
	'version' => 1
));

// Send notification emails and redirect

The object seems to be published correctly. What's not working correctly is that attribute data is not being saved correctly. The only attribute that is saved correctly is the user account. Do I need to get the user account by reference (same as the contentObjectAttributes array)? Like this:

$userAccountObject = & eZUser::fetch($contentObjectAttributes[2]->ContentObjectID);

Regards,
Rob Pratt
rpratt(at-sign)wordandsound.com

Claudia Kosny

Wednesday 30 August 2006 12:49:22 pm

Hello Rob,

For me it worked once I fetched the version of the contentobject and then changed the contentattributes of this version.
Something like thsis:

   //create and instantiate the object, assign a node

    $version =& $contentObject->version(1); //it is a new contentobject, thus version 1
    $version->setAttribute('created', $now);
    $version->setAttribute('modified', $now);
    $version->setAttribute('status', EZ_VERSION_STATUS_DRAFT);    
    $version->store();
    
    $contentObjectAttributes =& $version>contentObjectAttributes();

   //set and store the contentobjectattributes
  
  //publish the node

Hope it helps

Claudia

You must be logged in to post messages in this topic!

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