3

I'm creating nodes using a custom modules

$node = new stdClass();
$node->type = $link['content_type'];

node_object_prepare($node);

$node->uid = $user->uid;
$node->name = $user->name;

$node->title = $html['title'];
$node->language = LANGUAGE_NONE;
$node->body[$node->language][0]['value'] = $html['html'];
$node->body[$node->language][0]['summary'] = $html['summary'];
$node->body[$node->language][0]['format'] = 'filtered_html';

$node->menu['enabled'] = 0; // 1 to enable providing a link in main menu
$node->menu['link_title'] = urlencode($html['title']);
$node->menu['description'] = urlencode($html['summary']);
$node->menu['parent'] = 'main-menu:0';

$node->menu['weight'] = 5;
$node->path['alias'] = urlencode($html['title']) . time();
$node->comment = 1;

$node->status = 1;        // 1 means published
$node->promote = 0;
$node->revision = 0;

$node->changed = $_SERVER['REQUEST_TIME'];
$node->created = $_SERVER['REQUEST_TIME'];

node_submit($node);
@node_save($node);

$node->path['alias'] .= '+' . $node->nid;

node_submit($node);
@node_save($node);

db_update('node_revision')
    ->fields(array('uid' => $node->uid))
    ->condition('vid', $node->vid)
    ->execute();

But now I need to assign each node a I create a workbench section, so I tried doing this:

$node->workbench_access = array('66');

node_submit($node);
@node_save($node);

$node->path['alias'] .= '+' . $node->nid;

node_submit($node);
@node_save($node);

db_update('node_revision')
    ->fields(array('uid' => $node->uid))
    ->condition('vid', $node->vid)
    ->execute();

This add the workbench access id temporarily, but when the page is refreshed it doesn't apply it. Is there a way to assign a node to a workbench section using php?

1 Answer 1

0

You could try an insert query to inject the access ID, node ID and access scheme into the workbench_access_node table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.