This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit ezplatform.com

eZ Community » Forums » Extensions » Updating the modified by field on a...
expandshrink

Updating the modified by field on a content object using eZ API / PHP

Updating the modified by field on a content object using eZ API / PHP

Friday 08 October 2010 10:57:49 am - 3 replies

Does anyone have any pointers on how I can update the modified by field on a content object using PHP and the eZ API. I've got the update and publish functionality working, but I'm curious how I would go about setting the user who modified the object.

I thought it would be similar to the creation process:

$params = array();
$params['class_identifier'] = 'image';
$params['creator_id'] = $user->attribute( 'contentobject_id' ); //using the user extracted above
$params['parent_node_id'] = $parent_node->attribute( 'node_id' ); //pulling the node id out of the parent

but I thought I'd just have to update the modifier_id field, so I tried this:

<span class="Apple-style-span" style="font-size: 13px; " mce_style="font-size: 13px;" mce_fixed="1">$params = array();</span><span class="Apple-style-span" style="font-size: 13px; " mce_style="font-size: 13px;" mce_fixed="1">
</span><span class="Apple-style-span" style="font-size: 13px; " mce_style="font-size: 13px;" mce_fixed="1">$params['modifier_id'] = $user->attribute( 'contentobject_id' ); //using the user extracted above</span><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="" mce_fixed="1">
</span></font>

Unfortunately...no such luck. Any pointers would be appreciated.

Thanks!

Friday 08 October 2010 1:23:56 pm

Hi Conrad

If you're talking about the modified timestamp, here's the tip :

$myContentObject->setAttribute( 'modified', $myTimestamp );
$myContentObject->store( array( 'modified' ) ) ;

Friday 08 October 2010 3:08:41 pm

@Jerome, I think what Conrad want is to be able to set the modifier(person) id for the edit of an object.

@Conrad, if I'm not wrong there is no modifier_id as the modifier of an object is the creator of the new version of an object.

For example you create a complete new object and publish it:

version #1, creator id=45 => object_id=5454, current version = 1

Then you edit the object (means you should create a new version of the object):

version #2, creator id=46 => object_id=5454, current version = 2

So currently the object of id 5454 is at current version set to #2, the creator of version #2 is of id 46. So this means the current modifier of object id 5454 is of id 46. See what I mean?

If you are trying to edit an object in PHP by directly accessing the attributes then store it without creating a new version, you're doing it wrong, or would I say not in the recommended way.

You can have a look at the file:

´╗┐kernel/content/edit.php

Modified on Friday 08 October 2010 3:10:32 pm by Quoc-Huy NGUYEN DINH

Wednesday 13 October 2010 7:12:08 pm

(Sorry for the delayed response, didn't have the notifications enabled)

Ahhh...gotcha, that's perfect guys! Thank you so much.

@Jerome, I was in fact looking for a way to set the id of the user that modified the object, but I think what Quoc mentioned makes sense. I'm going to give that a shot...however, I just came across a need to update the modified timestamp, so thank you as well for your input.

@Quoc, I see what you're saying...that does indeed make sense. I'm going to try it that way and see how I make out.

Cheers!

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from