I’m hoping someone can help me here because my brain is about to explode!
I am using the simpleWorkflow validator in my model. It’s a great extension, thank you so much Raoul.
I have a scenario with contributors, reviewers, a master editor a publisher etc.
In order to provide unique workflows for each role I set up my swSource file with a switch/case construct - example.
$level = MyUtils::userLevel();
switch($level)
{
case User::CONTRIBUTOR_USER:
$statusArray = array(
'initial' => 'draft',
'node' => array(
array('id'=>'draft', 'transition'=>array(
'submitted'=>'MyUtils::contributorMail($this->id,0)'
)
),// CONTRIBUTOR
array('id'=>'revise', 'transition'=>array(
'submitted'=>'MyUtils::contributorMail($this->id,1)',
'withdrawn'=>'MyUtils::contributorMail($this->id,2)'
)
),// CONTRIBUTOR
array('id'=>'withdrawn'),// CONTRIBUTOR
array('id'=>'submitted'), // editor or contibuter
array('id'=>'rejected'), // CONTRIBUTOR
array('id'=>'accepted'), // publisher
array('id'=>'on-hold'), // publisher
array('id'=>'scheduled') // end of the line for all users
)
);
break;
case User::REVIEWER_USER:
$statusArray = array(
'initial' => 'draft',
'node' => array(
array('id'=>'draft'), // CONTRIBUTOR
array('id'=>'revise'),// CONTRIBUTOR
array('id'=>'withdrawn'), // CONTRIBUTOR
array('id'=>'submitted',
'transition'=>array(
'accepted'=>'MyUtils::reviewerMail($this->id,1)',
'revise'=>'MyUtils::reviewerMail($this->id,0)',
)), // editor or contibuter
array('id'=>'rejected'), // CONTRIBUTOR
array('id'=>'accepted'), // publisher
array('id'=>'on-hold'), // publisher
array('id'=>'scheduled') // end of the line for all users
)
);
break;
So each user role has options based on their role, I am not sure if this is best practice but at least this part is working.
I am also able to send an email using a method in a component called ‘MyUtils’, I simply pass the document ID and the mode or function.
All is working well, except it seems sometimes a reviewer will be a contributor and sometimes a master editor will be a contributor.
Contributor should be the only one who can pass his own ‘draft’ document to ‘submitted’.
Within this workflow source document I do not seem to be able to establish what the ID of the document is. I can do a down and dirty $_GET[‘id’] because on an update I have this is the URL but then I have to check if $_GET[‘id’] is set and it’s just not working. I also tried setting an constraint but that didn’t seem to work.
I don’t quite understand how the swSource document works but it seems to be like a configuration file that is loaded when required so I don’t think that the document (record) id is available at this time.
Next I am going to try a constraint again. Using something like.
array('id'=>'draft',
'constraint'=>'MyUtils::isOwner($this->id)',
'transition'=>array(
'submitted'=>'MyUtils::contributorMail($this->id,0)'
)
),
Any help or advice would be much appreciated.
I am using the original version of this extension, should I upgrade?
doodle 