Problems with attributes of the User datatype in eZContentFunctions

Author Message

Eirik Alfstad Johansen

Saturday 19 February 2011 4:36:01 am

The eZContentFunctions (as described in http://share.ez.no/learn/ez-publish/creating-ez-publish-objects-in-php) have made it significantly easier to create and update objects.

I am, however, experiencing some problems when it comes to creating and updating attributes based on the User datatype.

If I've understood things correctly, data should be formated to fit the fromString method of the individual datatype, and according to the fromString method for eZUserType, data should look like this (details separated by pipe):

login|email|password_hash|hash_identifier|is_enabled

However, this causes no changes to the data when updating (eZContentFunctions::updateAndPublishObject) and an empty user attribute with just a user ID when creating a new object (eZContentFunctions::createAndPublishObject).

Any ideas what could be wrong here?

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Carlos Revillo

Monday 21 February 2011 3:00:43 am

Hi. I'm using that too, and i found some similar issue when providing same e-mail for different users...

probably not... but is this your case?

Eirik Alfstad Johansen

Monday 21 February 2011 4:43:53 am

I'm not surprised that it doesn't work with the same email for different users since eZ usually requires (depending on its settings) a unique email pr user. However, in my case, I'm setting a unique email, so it doesn't make sense.

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Carlos Revillo

Monday 21 February 2011 5:06:54 am

Yeah, that's normal case, but you can set it to allow same email for different users. fromString method didn't take in account that. it's fixed in the master though.

just wondered if that could be your case. otherwise, dunno what could it be...

Eirik Alfstad Johansen

Monday 21 February 2011 6:02:47 am

Does that mean that you've got it working? If so, do you have some sample code I could compare against?

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Carlos Revillo

Monday 21 February 2011 7:10:08 am

Actually i'm using it for creating new users coming from my custom login handler. i mean, user type their login and password, then a webservice is called. this webservice returns an xml with all the user info. following code is part of my function. let me know if i can help you.

$params['class_identifier'] = 'user';
$params['creator_id'] = $ini->variable( "UserSettings", "UserCreatorID" );;
$params['parent_node_id'] = $parent_node_id; //pulling the node id out of the parent
$params['section_id'] = eZContentObjectTreeNode::fetch( $parent_node_id )->attribute( 'object' )->attribute( 'section_id' ); // because for the project needs we need several users sections
$attributesData = array();
$attributesData['name'] = $nombre;
$attributesData['surname'] = $apellidos;
$attributesData['user_account'] = "$identifier|$mail|" . md5( $password ) . "|md5_user|0"; // last 0 means disabled account
$params['attributes'] = $attributesData;  
$user = eZContentFunctions::createAndPublishObject( $params );

Eirik Alfstad Johansen

Thursday 24 February 2011 9:52:59 am

Thanks for the tip, Carlos. As it turns out, I had a bug in my code, so now it works fine for registering new users. However, it's still not updating the data for existing users. And as far as I can see, the data format should be the same.

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

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 02:13:08
Script start
Timing: Jan 18 2025 02:13:08
Module start 'layout'
Timing: Jan 18 2025 02:13:08
Module start 'content'
Timing: Jan 18 2025 02:13:10
Module end 'content'
Timing: Jan 18 2025 02:13:10
Script end

Main resources:

Total runtime1.8043 sec
Peak memory usage4,096.0000 KB
Database Queries69

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 589.3359152.6563
Module start 'layout' 0.00640.0040 741.992239.5000
Module start 'content' 0.01041.7924 781.4922580.0781
Module end 'content' 1.80280.0015 1,361.570316.0938
Script end 1.8043  1,377.6641 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00340.1881160.0002
Check MTime0.00140.0775160.0001
Mysql Total
Database connection0.00090.052510.0009
Mysqli_queries1.735996.2074690.0252
Looping result0.00080.0419670.0000
Template Total1.761297.620.8806
Template load0.00240.133220.0012
Template processing1.758897.479320.8794
Template load and register function0.00010.005510.0001
states
state_id_array0.00180.099610.0018
state_identifier_array0.00150.080520.0007
Override
Cache load0.00210.1137280.0001
Sytem overhead
Fetch class attribute can translate value0.00060.035120.0003
Fetch class attribute name0.00140.080180.0002
XML
Image XML parsing0.00060.031420.0003
class_abstraction
Instantiating content class attribute0.00000.0017110.0000
General
dbfile0.00080.0465160.0001
String conversion0.00000.000640.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
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
7content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/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
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 21
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs