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

eZ Community » Forums » Setup & design » Approval workflow and section

Approval workflow and section

Approval workflow and section

Wednesday 07 May 2014 7:28:52 pm - 7 replies

i need to create an approval workflow to limit certain user: they can publish contents in a part of the site and only edit/create (waiting an approvation) in other parts.

I have created a Users Group “gruppo Segreteria” and a new section “Segreteria”.

This is my Contents Structure:
Home (Section: Standard)
 - Subtree A (Section: Standard)
 --  node a1 (Section: Standard)
 -- node a2 (Section: Standard)
 - Subtreee B (custom section: “sezione Segreteria”)
 -- node b1 (custom section: “sezione Segreteria”)
 -- node b2 (custom section: “sezione Segreteria”)

The section “sezione Segreteria” is the part of the site where users of “gruppo Segreteria” can publish contents directly.

In Setup > Workflow i create a workflow with two events:
 - one for Standard section (only admin or editor can publish directly, they not affected by the event)
 - one for “sezione Segreteria” section (admin, editor and “gruppo Segreteria” user can publish directly, they not affected by the event)

I think that’s all and i start tests, so now start the strange things sad.gif Emoticon
A “gruppo Segreteria” user can:
 - create a new child of Subtree B -> no problem, publish content directly
 - Edit an existing node (i.e. “node b1”) ->  no problem, publish content directly
 - Edit Subtree B -> the problem: can’t publish directly, the new version waiting in my pending list.

I can’t figure out this behavior Subtree B has the custom section, like its child.

I’m using: “Community Project 2012.6”.

Anyone can help me?
Thanks in advance,

Modified on Wednesday 07 May 2014 7:29:58 pm by Matteo Monti

Thursday 08 May 2014 5:32:23 pm

I’m trying to go further thus i debug the kernel to see what happens under the hood:

I’m looking for a solution in kernel/classes/workflowtypes/event/ezapprove/ezapprovetype.php, function “execute”.
Every time i print the variable $workflowSections it contain only the first event of my workflow (the first is for the Standard section).

And this is what happens when i try to publish node “Subtree B” (section “sezione Segreteria”,  parent: Home, standard section) 

variable $section is 8  (the custom section id)

Then this condition
if ( !in_array( $section, $workflowSections ) && !in_array( -1, $workflowSections ) )

is true.
This causes the change of variable $section, now it takes the parent’s section id:

$parentObject = $parent->object();
$section = $parentObject->attribute( 'section_id');

so $section now is: 1 (Standard section id).

any help will be appreciated

Thursday 08 May 2014 11:59:23 pm

The description of your workflows is lacking. Are you using some multiplexer, or just 2 approval events directly on the main workflow? Are you using only pre-publish trigger?

As for the line of code you mention, if the condition is true it will jump to $correctSection = true; , not to the parent switch.

Friday 09 May 2014 12:03:05 am

ps I hope you use debug.ini with kernel-workflow-approve to get some understanding of this - or a proper debugger blunk.gif Emoticon

Friday 09 May 2014 12:11:12 am

If the problem is that the data for the 2nd event gets mixed up with the data from the 1st event, your problem comes more likely from the wrong $inExcludeGroups, I think.

Can you examine the contents of $process and $event to make sure those are not mixing up the events?

Or are you only examining ever event 1, because that's the one which kicks in and you never get to execute event 2?

That would make more sense:

- node at root of section is examined => not in section

- its parents are examined => in std section

- approval kicks in

If this is the case, maybe you can put the 1st approval on a separate workflow, chained via a multiplexer based on content class, so that it is not triggered by node B...

Friday 09 May 2014 12:20:53 am

Last but not least: it seems that the code which checks the parent node was added by Kirill Subbotin in 2005, to fix this bug: (funnily enough reported by an italian).

I think that that code is wrong:

- it is not true that a new object version is created when adding a section. And since approval can only be hooked to before-publish, it does not really fit

- to check parent section of a to-be-created object, I am not sure that that code is correct, either

- since that time we have added add-location triggers, and the add-location approval event which you can find in ezworkflowcollection extension


So, if you confirm my analysis, open a new issue in Jira

Friday 09 May 2014 10:49:56 am

Hi Gaetano,
first of all thank for your replies.

You’re right, my description is lacking:
I have 2 Workflows in Standard Workflow Group:
 - one for Event / Approve
 - one for Event / Update hidden field (for a postponed publication)

In the first workflow (approve) i have 2 events: one for standard section and one for custom section.
I also tried to create an another Event / Approve workflow but the result is the same.. thus i stepped backward to original situation.

I mean the entire condition:
both $section and “-1” aren’t in $workflowSection, then it’s going down to the foreach

 if ( !in_array( $section, $workflowSections ) && !in_array( -1, $workflowSections ) )
            $assignedNodes = $object->attribute( 'assigned_nodes' );
            if ( $assignedNodes )
                foreach( $assignedNodes as $assignedNode )
                    $parent = $assignedNode->attribute( 'parent' );
                    $parentObject = $parent->object();
                    $section = $parentObject->attribute( 'section_id');
                    if ( in_array( $section, $workflowSections ) )
                        $correctSection = true;
            $correctSection = true;

Am i thinking wrong?

ehm.. before your comment i’m using print function like “var_dump”.. sad.gif Emoticon


Now i will try some test, a multiplexer and debug.ini. During the day, I will answer the other questions.
Thank you

Modified on Friday 09 May 2014 10:53:18 am by Matteo Monti

Friday 09 May 2014 6:45:04 pm

i tried multiplexer or other workaround but the result is always the same, can’t publish directly the node “Subtree B”.

With debug.ini i see clearly this behavior:
 - Subtree B (the problem)
Only the Standard workflow event kicks in, thus the edit going to waiting a wrong approvation:
We are going to create approval -> Defferred to cron
If I change the order of my two events in my main workflow there are 2 cycles the workflow run until the Standard section.

 - Node “node b1”
No problem, publish directly:
“we are not going to create approval”

Your analysis seems right.
..Ok, now i’m start to thinking it’s a bug..  Monday i’m going to say hello to JIRA happy.gif Emoticon


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

36 542 Users on board!

Forums menu

Proudly Developed with from