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.

CommentFileSizeAuthor
#9 workflow_II.png81.12 KBspellbinder
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

_randy’s picture

You'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.

spellbinder’s picture

Are there any examples of custom batch functions? Best practices for where to place function, my thoughts are put it in maestro_content_publish.module

_randy’s picture

Our 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.

spellbinder’s picture

I think this link is wrong, or nextide has been hacked by http://www.instantfwd.com/

_randy’s picture

Give it a bit. A very recent DNS change may have not propagated to you yet..

spellbinder’s picture

Hi,

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

spellbinder’s picture

Found the module article
http://www.nextide.ca/creating_a_new_task_for_maestro

Thanks. I might have all I need

spellbinder’s picture

I 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

spellbinder’s picture

FileSize
81.12 KB
spellbinder’s picture

Status: Active » Closed (fixed)

Excellent assistance, what a ubiquitious workflow.