Forums / Developer / Changing user login and/or owner ID

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

eZ debug

Timing: Jan 20 2025 14:28:05
Script start
Timing: Jan 20 2025 14:28:05
Module start 'content'
Timing: Jan 20 2025 14:28:05
Module end 'content'
Timing: Jan 20 2025 14:28:05
Script end

Main resources:

Total runtime0.8803 sec
Peak memory usage4,096.0000 KB
Database Queries211

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 588.9766180.8281
Module start 'content' 0.00630.7632 769.8047658.5313
Module end 'content' 0.76950.1108 1,428.3359345.0547
Script end 0.8802  1,773.3906 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.4579210.0002
Check MTime0.00140.1618210.0001
Mysql Total
Database connection0.00080.087310.0008
Mysqli_queries0.778888.46552110.0037
Looping result0.00280.32012090.0000
Template Total0.855497.220.4277
Template load0.00190.216220.0010
Template processing0.853596.948520.4267
Template load and register function0.00010.014410.0001
states
state_id_array0.00030.034210.0003
state_identifier_array0.00060.072320.0003
Override
Cache load0.00170.1940440.0000
Sytem overhead
Fetch class attribute can translate value0.00130.146440.0003
Fetch class attribute name0.00210.2391110.0002
XML
Image XML parsing0.00420.482640.0011
class_abstraction
Instantiating content class attribute0.00000.0055160.0000
General
dbfile0.00991.1191410.0002
String conversion0.00000.000730.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
8content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 34
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs