Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a workflow, that I can assign users to specific steps in the approval process. I would like the last approver in the process to be the content owner/author the content will have permissions set up so only author can edit the content.
Comment | File | Size | Author |
---|---|---|---|
#9 | workflow_II.png | 81.12 KB | spellbinder |
Comments
Comment #1
_randy CreditAttribution: _randy commentedYou'll have to alter the owner of the node then. You can do that through a custom batch function task that takes the node ID and alters the UID of the node and saves the node.
Comment #2
spellbinder CreditAttribution: spellbinder commentedAre there any examples of custom batch functions? Best practices for where to place function, my thoughts are put it in maestro_content_publish.module
Comment #3
_randy CreditAttribution: _randy commentedOur blog has a how-to: http://www.nextide.ca/maestro_how_to , namely the section on how to create a batch function.
I would highly recommend that you do NOT hack any of the Maestro modules to add code to them as those modules would have to be overwritten with any updates to Maestro.
Create your own module and use the Maestro hooks and API to achieve what you're after.
As far as what you're after, You could write your own batch function that calls the publishNode function from within your own custom function so that you can do the publish and UID change all in one shot rather than having two Maestro tasks that run publishNode and then run your batch function.
Comment #4
spellbinder CreditAttribution: spellbinder commentedI think this link is wrong, or nextide has been hacked by http://www.instantfwd.com/
Comment #5
_randy CreditAttribution: _randy commentedGive it a bit. A very recent DNS change may have not propagated to you yet..
Comment #6
spellbinder CreditAttribution: spellbinder commentedHi,
I have read an read the blog post on nexttide. I can not find the piece for
"The best approach is to write your own Maestro module as described in our blog post so that you can easily maintain your own custom codebase." Unfortunately I think I am asking something basic that every drupal coder knows.
Can I put the code for my batch processes
function spellbinder_maestro_handler_options () {
$handlers = array(
'MaestroTaskTypeBatchFunction' => array(
'changeAuthor' => t('Make First Reviewer The Author')
),
);
return $handlers;
}
in a module called /all/modules/spellbinder/spellbinder.module ?
or does it have to sit in the maestro directory. SOrry for being so dense. I am just trying to get it right.
Thank you
Comment #7
spellbinder CreditAttribution: spellbinder commentedFound the module article
http://www.nextide.ca/creating_a_new_task_for_maestro
Thanks. I might have all I need
Comment #8
spellbinder CreditAttribution: spellbinder commentedI have this working as
function maestro_publishNodeChangeAuthor($queue_id, $process_id) {
$maestro = Maestro::createMaestroObject(1);
$content_type = $maestro->engine()->getProcessVariable('content_type', $process_id);
$nid = maestro_getNodeId($process_id,$content_type);
if ($nid > 0) {
$node = node_load($nid);
$node->uid = $node->field_tenantrole['und']['0']['uid'];
if (module_exists('revisioning')) {
// Only support presently to publish the last revision
$latest_vid = revisioning_get_latest_revision_id($nid);
$last_node_revision = node_load($nid, $latest_vid);
_revisioning_publish_revision($last_node_revision);
} else {
$node->status = NODE_PUBLISHED;
node_save($node);
}
drupal_set_message(print_r($node->field_tenantrole['und']['0']['uid'] , true) . " New {$content_type} and ". print_r($process_id, true) ." has been published");
return TRUE;
} else {
return FALSE;
}
}
I would like to get it working without publish
function maestro_changeAuthorToTenantRole($queue_id, $process_id) {
$maestro = Maestro::createMaestroObject(1);
$content_type = $maestro->engine()->getProcessVariable('content_type', $process_id);
$nid = maestro_getNodeId($process_id,$content_type);
if ($nid > 0) {
$node = node_load($nid);
$node->uid = $node->field_tenantrole['und']['0']['uid'];
drupal_set_message(print_r($node->field_tenantrole['und']['0']['uid'] , true) . " Author changed to tenant " . print_r($node->uid , true));
return TRUE;
} else {
return FALSE;
}
}
With the second function The output indicates a change in ownership, but it does not happen
Comment #9
spellbinder CreditAttribution: spellbinder commentedComment #10
spellbinder CreditAttribution: spellbinder commentedExcellent assistance, what a ubiquitious workflow.