Importing: Update entry if it already exists

Author Message

Siniša Šehović

Thursday 07 October 2004 1:17:49 am

Hi Paul

Please help:-)

Something strange happend!?
After importing hash into user table there is hash that I have created and I can't login but if I go to user in admin and "change" password with same password(hash import is demo password) "demo" i see that in user table is different hash of demo?!?!
How is that possible?

Best regards,
Sinisa

---
If at first you don't succeed, look in the trash for the instructions.

Siniša Šehović

Thursday 07 October 2004 2:19:32 am

Hi

I have figured out what was wrong!:)-)
Password hash is produced like username\password.
Now everything works great:)

S.

---
If at first you don't succeed, look in the trash for the instructions.

Paul Forsyth

Friday 08 October 2004 12:40:05 am

Glad it works! I was away for most of yesterday.

Paul

Lazaro Ferreira

Wednesday 20 October 2004 1:51:47 am

Paul,

I have read all the thread, and I have picked up this piece of code, that create and publish an user object

$ini =& eZINI::instance();

$userClassID = $ini->variable( "UserSettings", "UserClassID" );
$class =& eZContentClass::fetch( $userClassID );

$userCreatorID = $ini->variable( "UserSettings", "UserCreatorID" );
$defaultSectionID = $ini->variable( "UserSettings", "DefaultSectionID" );
$defaultUserPlacement = $ini->variable( "UserSettings", "DefaultUserPlacement" );

$contentObject =& $class->instantiate( $userCreatorID, $defaultSectionID, false);

$nodeAssignment =& eZNodeAssignment::create( array(
                                                   'contentobject_id' => $contentObject->attribute( 'id' ),
                                                   'contentobject_version' => 1,
                                                   'parent_node' => $defaultUserPlacement,
                                                   'is_main' => 1
                                                  )
                                           );
$nodeAssignment->store();
    
// Set a status for the content object version
$contentObjectVersion =& $contentObject->version($contentObject->attribute( 'current_version' ) );
$contentObjectVersion->setAttribute( 'status', EZ_VERSION_STATUS_DRAFT);
$contentObjectVersion->store();

// Set the members attributes
$contentObjectAttributes =& $contentObject->attribute('data_map');

$firstNameAttribute = $contentObjectAttributes['first_name'];
$lastNameAttribute = $contentObjectAttributes['last_name'];
$userAccountAttribute = $contentObjectAttributes['user_account']->content();

// Now set the details
$firstNameAttribute->setAttribute("data_text", "Enter first name");
$firstNameAttribute->store();
    
$lastNameAttribute->setAttribute("data_text", "Enter second name");
$lastNameAttribute->store();
    
$userAccountAttribute->setAttribute("login", "Choose login");
$userAccountAttribute->setAttribute("email", "Choose email");

// Entered md5 sum of 'publish'. Replace with hash of your own. Make sure the hash type matches.
$userAccountAttribute->setAttribute("password_hash", "9b6d0bb3102b87fae57bc4a39149518e");
    
// Keep the password type as 2. This is the default for eZ publish but look in ezuser.php for more options.
$userAccountAttribute->setAttribute("password_hash_type", 2);
$userAccountAttribute->store();

// Now publish the object.
$operationResult = eZOperationHandler::execute( 'content', 
                                                'publish',
                                                array( 'object_id' => $contentObject->attribute( 'id' ),
                                                       'version' => $contentObject->attribute('current_version' ) ) );

So, my understanding is that here I have all ezp API needed to create and publish my own content objects from my php module extension

Is that right ?

Lazaro
http://www.mzbusiness.com

Paul Forsyth

Wednesday 20 October 2004 2:10:28 am

Some of it, yes. Your own needs may differ of course. The code above is just an example. Search the forums for snippets of this code and you will see it used in other ways.

You could always use the code documentation found at http://pubsvn.ez.no/doxygen/

Btw, can yu reply to the original thread and not this one. Its easier to follow.

paul

First Last

Saturday 30 July 2005 9:45:12 am

Thank you for import script, but could you post format of CSV file to import? I don't know, how to prepare CSV file to be able to import it.

First Last

Monday 08 August 2005 11:05:28 am

Now I know how to import text fields, but could anyone help me how to import images?

Massimiliano Bariola

Saturday 18 March 2006 1:03:24 pm

Hi,

I tried the code provided to change the name of a node, but it does not seem to work. my code does not fail, but the name remains the same.

Please can anyone help me?

thank you!

Massimiliano Bariola

Saturday 18 March 2006 1:48:39 pm

I found it. $contentObject->rename($newname). 4 hours to find it ... sigh.

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