Thursday 21 February 2008 2:55:03 am
Hi. I want to remove and append relations from a user attribute (I have modified the user class to meet my needs, adding an "object relations" datatype). This is my code in the module:
$uid =& eZUser::currentUserID();
$user =& ezUser::fetch( $uid , true );
$contentObject =& $user->contentObject();
$contentObjectAttributes =& $contentObject->ContentObjectAttributes();
$actosObject =& $contentObjectAttributes[6];
$actosContent =& $contentObjectAttributes[6]->content();
print_r($actosContent);
$contentFileObjectID = 3264;
$priority = 999;
$actosContent['relation_list'][] = eZObjectRelationListType::appendObject( $contentFileObjectID, $priority, $actosObject );
print_r($actosContent);
If I print the contents of $actosContent before and after, I get: Before:
Array
(
[relation_list] => Array
(
[0] => Array
(
[priority] => 1
[contentobject_id] => 3201
[contentobject_version] => 2
[node_id] => 3176
[parent_node_id] => 3174
[contentclass_id] => 43
[contentclass_identifier] => acto
[identifier] =>
[is_modified] =>
)
)
)
After eZObjectRelationListType::appendObject :
Array
(
[relation_list] => Array
(
[0] => Array
(
[priority] => 1
[contentobject_id] => 3201
[contentobject_version] => 2
[node_id] => 3176
[parent_node_id] => 3174
[contentclass_id] => 43
[contentclass_identifier] => acto
[identifier] =>
[is_modified] =>
)
[1] => Array
(
[identifier] =>
[priority] => 999
[contentobject_id] => 3264
[contentobject_version] => 1
[node_id] => 3175
[parent_node_id] => 3174
[contentclass_id] => 43
[contentclass_identifier] => acto
[is_modified] =>
[object] => ezcontentobject Object
(
[PersistentDataDirty] =>
[ID] => 3264
[Name] => Acto 01
[CurrentLanguage] => esl-ES
[ClassName] =>
[ClassIdentifier] =>
[DataMap] => Array
(
)
[ContentActionList] =>
[ContentObjectAttributes] => Array
(
)
[MainNodeID] => 3175
[SectionID] => 11
[OwnerID] => 14
[ClassID] => 43
[IsPublished] => 0
[Published] => 1203505438
[Modified] => 1203505438
[CurrentVersion] => 1
[Status] => 1
[RemoteID] => 95e91d5c7525f97f334a6291c7a1d706
)
)
)
)
Dont know why the second object relation has an "ezcontentobject Object" inside... is this correct? Dont know either if I should do:
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $uid,'version' => 1 ) );
or
$contentObjectAttributes[6]->setContent( $actosContent );
$contentObjectAttributes[6]->store();
or both in order to save the changes? BTW, how can I REMOVE a relation? Im trying this but has no effect:
eZObjectRelationListType::removeRelatedObjectItem( $actosObject , 3266 );
Thanks.
|