Just to add some more info - BrainV helped me develop the following code for a custom module - called publishtrigger here. I wanted the approve button to publish the Player node and then assign it to the "contentadmin" user, which has ID 6 in my case...
<?php
/**
* Implementation of hook_perm().
*/
function publishtrigger_perm() {
return array('approve nodes');
}
/**
* Implementation of hook_menu().
*/
function publishtrigger_menu() {
$items['approve/%'] = array(
'title' => 'Approve',
'page callback' => 'publishtrigger_approve_node',
'page arguments' => array(1),
'access arguments' => array('approve nodes'),
'type' => MENU_CALLBACK,
);
return $items;
}
/**
* Implementation of hook_link().
*/
function publishtrigger_link($type, $object, $teaser = FALSE) {
// Show this link at the bottom of nodes of the Player type which are not yet
// owned by contentadmin (UID 6).
if ($type == 'node' && $object->type == 'player') {
// Make sure user has permission to approve nodes.
if (user_access('approve nodes')) {
$links = array();
if ($object->uid != 6 || $object->status == 0) {
// Node is not owned by contentadmin (UID 6), and therefore not approved.
$links['approve_link'] = array(
'title' => 'Approve',
'href' => 'approve/' . $object->nid,
);
}
else {
// Node is already approved
$links['approve_link'] = array('title' => 'Already approved');
}
return $links;
}
}
}
/**
* When this code is run, adjust the owner of the indicated node to 'contentadmin',
* UID 6.
*
* @param $nid
* The node id of the node we want to change the owner of.
*/
function publishtrigger_approve_node($nid) {
// Load the node.
$node = node_load($nid);
// Set the UID to 6 (for contentadmin).
$node->uid = 6;
// Publish the node
$node->status = 1;
// Save the node again.
node_save($node);
// Go back to the node page
drupal_goto($node->path);
}