Edit/Change a class attribute.

Author Message

James Hyatt

Monday 04 October 2004 5:07:26 am

Hi,

I have taken over development of an EZ site and I am wondering a few things, forgive me if they seem simple.

I have User class which has been set up in the administration (by the previous coder)

This holds all the usual data, name, email etc and some custom attributes.

One of these is 'weight' and this is set as an integer. This means that the user must enter a whole number but the client now wishes them to use decimals too. How can I switch this attribute to be 'float' instead?

One other question, one of the extended moduals will allow the user to enter a daily weight, this then needs to update the User Class weight attribute value for the user with the most recently entered daily date.

How can I access or update this value from php without having to use the /content/edit/ url. I want to update it directly from the modual code.

Is there eZUser::updateUser(); or something?

Regards

James

Silke Fox

Monday 04 October 2004 6:35:42 am

James,

Welcome... :)

It's not possible to change the datatype of an class attribute.
You'll have to add a new attribute of type "float" to your class and
migrate the values from the old attribute to the new one.

For updating the weight - custom user attributes are stored just like any
other content objects. Within your module you'll have to
- fetch the user's content object
- get current version of the object or create new one
- set attribute value
- store content object

Have a look at the import/ export contributions at http://ez.no/community/contributions/import_export to find out details on settings content object data.

Good luck,
Silke

James Hyatt

Monday 04 October 2004 8:14:32 am

Hi Silke,

Thank you,

I had assumed the only way was to delete the attribute and create a new one but with there being some 6,000 users I was hoping I could simply edit it.

I'll take a look at the link you sent me, I need abit of time to get into the EZ way of doing things. It can be frustraiting to hit such seamingly simple barriers.

Kind Regards,

James Hyatt

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