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.

eZ debug

Timing: Jan 19 2025 01:03:52
Script start
Timing: Jan 19 2025 01:03:52
Module start 'layout'
Timing: Jan 19 2025 01:03:52
Module start 'content'
Timing: Jan 19 2025 01:03:53
Module end 'content'
Timing: Jan 19 2025 01:03:53
Script end

Main resources:

Total runtime0.9415 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 590.7344152.6406
Module start 'layout' 0.00590.0042 743.375039.4766
Module start 'content' 0.01010.9297 782.8516548.2656
Module end 'content' 0.93990.0016 1,331.117212.1250
Script end 0.9414  1,343.2422 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.3614160.0002
Check MTime0.00140.1464160.0001
Mysql Total
Database connection0.00070.078610.0007
Mysqli_queries0.887494.2525570.0156
Looping result0.00060.0613550.0000
Template Total0.910996.820.4555
Template load0.00220.230120.0011
Template processing0.908896.522720.4544
Template load and register function0.00010.014610.0001
states
state_id_array0.00070.076410.0007
state_identifier_array0.00240.252320.0012
Override
Cache load0.00170.1855240.0001
Sytem overhead
Fetch class attribute can translate value0.00070.072220.0003
Fetch class attribute name0.00120.124850.0002
XML
Image XML parsing0.00130.142520.0007
class_abstraction
Instantiating content class attribute0.00000.001460.0000
General
dbfile0.00120.1284230.0001
String conversion0.00000.001040.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
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 18
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs