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.
|
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
|
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!
|