howto? update user settings

Author Message

John Moritz

Saturday 11 July 2009 5:08:18 am

I have added some attributes to the user class. One is a Date atribute which will represent the users birthday, one is a field for the user gender and many more.

I imported users in ezpublish from an existing community, but with missing those attributes which still exist in my old sql table "members".

Now i need a little script where i can update all ezpublish users.

I added the contentobject_id to my "members" table in sql.
So i know how to make the loop, i still dont know how i can update the userattributes on ezpublish. So i only need this short snippet, pls.

Max Keil

Saturday 11 July 2009 2:34:32 pm

Hi John,

you may searching for something like this?

//get the Object
$object = eZContentObject::fetch( your id );

//get the data map from this object
$dataMap = $object->attribute('data_map');

//set attribute "birthday"
$dataMap['birthday']->setAttribute( "data_int", $ts );
//store attribute "birthday"!
$dataMap['birthday']->store();

//store the object!
$object->store();

//clear the view cache for this object 
eZContentCacheManager::clearObjectViewCache( $object->attribute('id') );

Mit freundlichen Grüßen
Best regards

Max Keil

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

John Moritz

Monday 13 July 2009 3:08:10 pm

Thanks Max, this works great!

Can i save this as a new Version for the Object? As far as i can see, this will update the userobject without generating a new version.

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 31 2025 00:36:17
Script start
Timing: Jan 31 2025 00:36:17
Module start 'layout'
Timing: Jan 31 2025 00:36:17
Module start 'content'
Timing: Jan 31 2025 00:36:17
Module end 'content'
Timing: Jan 31 2025 00:36:17
Script end

Main resources:

Total runtime0.0348 sec
Peak memory usage4,096.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0057 588.1328151.2109
Module start 'layout' 0.00580.0044 739.3438220.6875
Module start 'content' 0.01020.0233 960.0313997.9141
Module end 'content' 0.03350.0013 1,957.945333.9922
Script end 0.0348  1,991.9375 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00257.1258140.0002
Check MTime0.00113.2549140.0001
Mysql Total
Database connection0.00072.122010.0007
Mysqli_queries0.003911.197430.0013
Looping result0.00000.034210.0000
Template Total0.00102.910.0010
Template load0.00082.270510.0008
Template processing0.00020.594210.0002
Override
Cache load0.00051.452510.0005
General
dbfile0.007220.623980.0009
String conversion0.00000.023340.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