Forums / Developer / contentobject status 5

contentobject status 5

Author Message

Claudia Kosny

Thursday 09 November 2006 12:37:00 am

Hi there

I have created a new datatype which stores some data in an external table.
In the function objectAttributeContent(...) I either want to fetch the data for the current version or, if the current version is a draft, the data of the published version.

The prolem I have is determining whether the the current version is a draft. My current code is like this:

$currentVersion =& $contentObjectAttribute->attribute('object_version');
$currentVersionNr = $currentVersion->attribute('version');
$currentVersionStatus = $currentVersion->attribute('status');

The version number is correct, but the status is set to 5.
According to the documentation the status for a draft is supposed to be 0, a status of 5 is not mentioned at all.

Any idea what is going on?

Claudia

Paul Forsyth

Thursday 09 November 2006 1:43:32 am

What type of object does your datatype return as content?

Looking at the object version class i see this:

define( "EZ_VERSION_STATUS_DRAFT", 0 );
define( "EZ_VERSION_STATUS_PUBLISHED", 1 );
define( "EZ_VERSION_STATUS_PENDING", 2 );
define( "EZ_VERSION_STATUS_ARCHIVED", 3 );
define( "EZ_VERSION_STATUS_REJECTED", 4 );
//define( "EZ_VERSION_STATUS_SHOWN", 5 );

which shows that status 5 is not used.

perhaps your datatype returns something else?

paul

Claudia Kosny

Thursday 09 November 2006 2:37:48 am

Hi Paul

here is the result of print_r($currentVersion):

ezcontentobjectversion Object
(
    [PersistentDataDirty] => 
    [CurrentLanguage] => 
    [ContentObjectAttributeArray] => 
    [DataMap] => 
    [TempNode] => 
    [VersionName] => 
    [VersionNameCache] => Array
        (
        )

    [ID] => 738
    [ContentObjectID] => 201
    [CreatorID] => 14
    [Version] => 5
    [Status] => 5
    [Created] => 1163067858
    [Modified] => 1163067858
    [WorkflowEventPos] => 0
    [UserID] => 0
    [LanguageMask] => 3
    [InitialLanguageID] => 2
)

As you can see I get a contentobjectversion as it should be.The object and the version itself is also correct, I can access the current content of all attributes correctly.

I get similar data for the current version if I fetch all versions of the object using contentobject->versions(false) and then check the data for the version that is currently edited.

Maybe a draft is only a draft with status 0 if it was stored as draft and the status 5 is simply for a toally new version? I have not checked any further as I spent already a considerable amount of time finding out why my code did not work as expected.At the moment my code works fine if I check for status equals 5 or 0 so I will leave it at that for now (unless you can point me to a better solution)

Regards

Claudia

Paul Forsyth

Thursday 09 November 2006 2:50:39 am

Just had a quick look at the latest eZ version and indeed it does have a new value:

define( "EZ_VERSION_STATUS_INTERNAL_DRAFT", 5 );

It allows the system to clean up objects which never became published.

So, your object is a system-created draft. Testing for both 0 and 5 will work.

Read this for more info:

http://pubsvn.ez.no/nextgen/trunk/doc/features/3.8/temporary_drafts.txt

Paul

Claudia Kosny

Thursday 09 November 2006 3:03:58 am

Hi Paul

Thanks a lot - now I don't need to worry whether my code will work or not. I will add the information to the online documentation.

Claudia