1

我网站上的用户可以添加自定义类型的节点(我们称之为“播放器”),但不能发布它们。实际上,他们需要在发布之前进行审核。管理员/版主发布它们后,我希望将所有者/发布者更改为相关的管理员/版主。这样用户就无法编辑它们,也可以跟踪谁批准了它们等。

我该怎么做?我认为它可能涉及操作/规则/工作流/工作流-ng 等,但我已经查看了每一个,似乎无法弄清楚如何使其工作!

4

3 回答 3

3

Another alternative is to write a short module that includes an 'approve' link using hook_link(). Point that link to a menu callback that changes the node's ownership from the current user to the user that clicked the 'Approve' link.

It could be nice, clean way of solving this, but requires a bit of Drupal knowhow. However, if you ask someone in the #drupal IRC channel on irc.freenode.net, they could show you how to get started, or even code it as a contributed module for you.

于 2009-08-26T13:23:20.217 回答
1

您可以在编辑播放器节点时手动执行此操作。最后有一组两个设置,您可以在其中更改节点创建者和创建时间。

或者,您是否可以授予非管理员用户创建节点的权限,但删除他们编辑这些节点的权限。可能有效,但对这些用户来说可能会很痛苦。

于 2009-08-26T12:45:19.160 回答
1

只是为了添加更多信息——BrainV 帮助我为自定义模块开发了以下代码——这里称为发布触发器。我希望批准按钮发布播放器节点,然后将其分配给“contentadmin”用户,在我的情况下,该用户的 ID 为 6...

<?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);
}
于 2009-08-28T14:50:19.503 回答