eZ Community » Forums » Developer » How to fetch drafts ?
expandshrink

How to fetch drafts ?

How to fetch drafts ?

Monday 11 October 2010 5:56:08 pm - 7 replies

Hello,

I would like to fetch all contents with "draft" status, and especially all drafts in a specific parent node.

I feel a bit embarrassed, because I've read the following note, regarding the "fetch (section, object_list ...":

"Note that fetching all draft objects that belong to a certain section is not supported"

Thus, what would be a nice workaround ?

Thanks a lot for your answers.

Tuesday 12 October 2010 12:27:48 am

Hello Again Samuel,

It sure sounds like fetching all draft objects is not provided by the built-in fetch functions.

Perhaps you could create your own custom fetch function which does provide this feature?

Cheers,

Heath

Tuesday 12 October 2010 12:44:09 am

Hello,

I think in a case like this I would learn from the content/draft module view and template code.

I would create your own custom fetch function to be similar in design to the draft_version_list.

http://doc.ez.no/eZ-Publish/Techn...t/Fetch-functions/draft_version_list

The following snippet is from, kernel/content/ezcontentfunctioncollection.php

static public function fetchDraftVersionList( $offset, $limit )    {        $userID = eZUser::currentUserID();        $draftVersionList =  eZPersistentObject::fetchObjectList( eZContentObjectVersion::definition(),                                                                   null, array(  'creator_id' => $userID,                                                                                 'status' => eZContentObjectVersion::STATUS_DRAFT ),                                                                   array( 'modified' => true,                                                                          'initial_language_id' => true ),                                                                   array( 'length' => $limit, 'offset' => $offset ),                                                                   true );        return array( 'result' => $draftVersionList );    }
static public function fetchDraftVersionList( $offset, $limit )    {        $userID = eZUser::currentUserID();        $draftVersionList =  eZPersistentObject::fetchObjectList( eZContentObjectVersion::definition(),                                                                   null, array(  'creator_id' => $userID,                                                                                 'status' => eZContentObjectVersion::STATUS_DRAFT ),                                                                   array( 'modified' => true,                                                                          'initial_language_id' => true ),                                                                   array( 'length' => $limit, 'offset' => $offset ),                                                                   true );        return array( 'result' => $draftVersionList );    }

I would first fetch all users and then per user iterate over their draft list as desired. Bingo problem solved.

This is also a good article about how to create custom fetch functions.

http://share.ez.no/learn/ez-publish/understanding-and-developing-fetch-functions

Cheers,

//kracker

Modified on Tuesday 12 October 2010 1:02:58 am by // kracker

Tuesday 12 October 2010 1:16:34 am

Hello Heath,

Yes, today I could create my own functions based on the code you mentioned, and I was successful ! blunk.gif Emoticon

(solution: function fetchDraftVersionList_in_a_node(): I've removed the user_id parameter, and added parent_node_id in order to fetch into a specific node)

Thus I went further into my project.

Now, I'm facing another problem ! blunk.gif Emoticon

Ezpublish doesn't allow users to edit other users drafts.

Thus I thought it could be possible to copy one draft to a second draft, but... the second draft is loosing the original parent id because this new draft is not linked to any contentobject_id ! sad.gif Emoticon

My objective is to allow people editing the same draft, without sending it for publication, for instance:

. user1 creates a new object, he starts editing it, and he saves it as a draft without sending for publication (= draft v1);

. user2 edits and modifies this draft... and saves it again as a draft (= draft v2);

... and so on ... (= draft v7)

. and then, user3 edits and modifies this "draft v7"... and send it for publishing;

I would really want ezpublish to allow a user to edit another user's draft.

I keep investigating and search for a solution... if you have hints, I'm interested.

Thank you.

Tuesday 12 October 2010 2:06:30 am

Samuel,

The default content module is limited in this regard.

I strongly suggest you look further into ezapprove2 which provides for editing of other peoples drafts before actual publish.

Otherwise you may find yourself having to build your own custom module view to provide the features you need.

There is no simple solution if you can't change your requirements to fit ezapprove2.

Cheers,

Heath

Tuesday 12 October 2010 10:50:25 am

Heath,

Yes, I have to say I'm limited with the default content module.

Before going any further with a custom solution, I'll try to get back to eZApprove2.

But eZApprove2 doesn't seem to work with eZp4: I can create a new workflow with a new "event/ezapprove2", but I cannnot configure it...

I will post again on the eZApprove2 forum.

Thank you for your help.

Tuesday 12 October 2010 11:04:59 am

Samuel,

I am using the very same eZApprove2 to power another eZ Publish 4.x site.

So your installation may need help but the extension software is fairly solid.

Best to post to the project forum though.

Cheers,

Heath

Tuesday 12 October 2010 3:01:44 pm

Hi Heath,
I found the solution!
There is a bug in the "affected section" template.
The solution is here:
http://projects.ez.no/ezapprove2/...ral/problem_saving_affected_sections
Then I started testing this extension, and seems to meet my requirements, thank you !
Now, I'm facing another issue.
If I select "Users select approvers themselves" parameter in my event/approve2.
When an editor modifies a content, as soon as he sends article for publication, there is an interface asking him to select users.... and when clicks on "select users", there is a kernel_error: not authorized to access this page.
What rule/policy do I have to activate to give them access ?
Thank you.

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from