How to fetch drafts ?

Author Message

Samuel Torton

Monday 11 October 2010 8:56:08 am

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.

Samuel Torton

Heath

Monday 11 October 2010 3:27:48 pm

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

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

kracker (the)

Monday 11 October 2010 3:44:09 pm

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/Technical-manual/4.x/Reference/Modules/content/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

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Samuel Torton

Monday 11 October 2010 4:16:34 pm

Hello Heath,

Yes, today I could create my own functions based on the code you mentioned, and I was successful ! ;-)

(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 ! ;-)

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 ! :-(

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.

Samuel Torton

Heath

Monday 11 October 2010 5:06:30 pm

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

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

Samuel Torton

Tuesday 12 October 2010 1: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.

Samuel Torton

Heath

Tuesday 12 October 2010 2: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

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

Samuel Torton

Tuesday 12 October 2010 6:01:44 am

Hi Heath,
I found the solution!
There is a bug in the "affected section" template.
The solution is here:
http://projects.ez.no/ezapprove2/forum/general/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.

Samuel Torton

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 29 2025 13:34:58
Script start
Timing: Jan 29 2025 13:34:58
Module start 'layout'
Timing: Jan 29 2025 13:34:58
Module start 'content'
Timing: Jan 29 2025 13:34:58
Module end 'content'
Timing: Jan 29 2025 13:34:58
Script end

Main resources:

Total runtime0.0160 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 588.0313151.1953
Module start 'layout' 0.00480.0031 739.226636.6250
Module start 'content' 0.00790.0066 775.8516106.3594
Module end 'content' 0.01440.0016 882.210945.9766
Script end 0.0160  928.1875 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002314.4532140.0002
Check MTime0.00116.8382140.0001
Mysql Total
Database connection0.00063.521010.0006
Mysqli_queries0.002515.905730.0008
Looping result0.00000.080410.0000
Template Total0.00127.310.0012
Template load0.00095.680410.0009
Template processing0.00031.598310.0003
Override
Cache load0.00063.527010.0006
General
dbfile0.002314.352080.0003
String conversion0.00000.071440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs