Changing user login and/or owner ID

Author Message

Piotrek Karaś

Thursday 15 May 2008 7:37:16 am

Hi,

We need to perform two risky operations (or one of them at least):
a) change user login in a situation where user class object name pattern is based on user login (it appears in the
b) change the ownership of a number of objects from one existing user to another.

Are there any existing solutions, scripts, or at least tutorials for that? Any advice?

Thanks,
Piotrek

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

André R.

Thursday 15 May 2008 8:07:10 am

Changing owner id:

$object->setAttribute('owner_id', $new_object_owner_id);
$object->store();

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Piotrek Karaś

Thursday 15 May 2008 8:36:48 am

You're kidding, right? Will that take care of all necessary references in the db? It can't be that easy ;)

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

André R.

Thursday 15 May 2008 1:13:28 pm

Hopefully it is that simple (I'm using that code on a couple of scripts) :)
On contentobject_version you have creator_id and user_id, but neither has anything to do with the owner of the object, the last one even looks unused in a trunk database.

Edit: I'm using it in a content edit handler, so in a cli script you need to clear content cache as well for the object.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Piotrek Karaś

Thursday 15 May 2008 6:23:11 pm

I was just wondering about what documentation says:

http://ez.no/doc/ez_publish/technical_manual/4_0/concepts_and_basics/content_management/the_content_object
<i>The object's owner contains a reference to the user who initially created the object. At any time, an object can only be owned by one user. This reference is set by the system the first time the object is published. The ownership of an object can not be manipulated and will not change even if the owner the object is removed from the system.</i>

"At any time, an object can only be owned by one user" - this sounds promising, but:

"The ownership of an object can not be manipulated..." - now, I wonder if this was written only because there was no GUI tool for that operation, or for some more technical reason...

Why didn't the ownership change make it as a default functionality?

Are we sure creator ID will not be mistaken for owner ID anywhere in the code?

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Kristof Coomans

Friday 16 May 2008 12:04:13 am

Hi Piotrek

Yes indeed, it's written there like this because there is no GUI by default in eZ Publish to change ownership of objects. However, there are some extensions out there for a long while which do the job: http://projects.ez.no/owner

It might be that in the admin and/or user interface there are captions like "Creator" where the actual owner of the object is listed. While there should actually be the creator of the first version.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Piotrek Karaś

Friday 16 May 2008 12:37:38 am

Thanks guys!

PS. Actually, I think it's good that these pieces of information are separated, because they represent different info. Object or version creator may be one thing, object current owner another one. Question remains: is better object ownership management in any eZ Publish roadmap? Will that ever make it to the core?

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Kristof Coomans

Friday 16 May 2008 2:40:35 am

It's not on the roadmap anywhere afaik. You might put an enhancement request in the issue tracker for it. Simply adding a "creator" field to the content object table in addition to the owner field would already get us further.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

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