How to edit / store user attributes within a extension

Author Message

Norman Leutner

Thursday 10 November 2005 3:25:11 pm

I've added a new attribute to the user class called "punkte" Datatype: Integer
Now i need to edit this attribute within one of my extensions.

I tried the following:

include_once( "kernel/classes/ezcontentobject.php" );
$userObject=eZContentObject::fetch('59');

$newuserObject =& $userObject->createNewVersion();

$dataMap =& $newuserObject->attribute ( 'data_map' );
$dataMap['punkte']->setAttribute( 'data_int', '5' );
$dataMap['punkte']->store();

My problem is that the attribte is set but not stored!

Has anyone a suggestion for me?

Mit freundlichen Grüßen
Best regards

Norman Leutner

____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

Bruce Morrison

Thursday 10 November 2005 3:46:29 pm

Hi Norman

You need to republish the object after changing the attribute.

Something like this should do the trick:

include_once( "kernel/classes/ezcontentobject.php" );
$userObject=eZContentObject::fetch('59');

$newuserObject =& $userObject->createNewVersion();

$dataMap =& $newuserObject->attribute ( 'data_map' );
$dataMap['punkte']->setAttribute( 'data_int', '5' );
$dataMap['punkte']->store();

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

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Norman Leutner

Saturday 12 November 2005 8:43:10 am

Thanks Bruce.
It´s been a little bit late that day ...
(12:25:11 am)

should have seen it by myself ;)

Mit freundlichen Grüßen
Best regards

Norman Leutner

____________________________________________________________
eZ Publish Platinum Partner - http://www.all2e.com
http://ez.no/partners/worldwide_partners/all2e_gmbh

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