我的網站上的用戶可以添加自定義類型的節點(我們稱之爲「播放器」),但無法發佈它們。實際上,他們需要在發佈之前進行調節。一旦管理員/管理員發佈了他們,我想將所有者/發佈者更改爲相關的管理員/管理員。這是爲了讓用戶無法編輯它們,因此可以跟蹤誰批准他們等。更改Drupal中發佈節點上的所有者
我該如何解決這個問題?我認爲它可能涉及操作/規則/工作流程/工作流程ng等,但我已經看過每一個,似乎無法弄清楚如何使其工作!
我的網站上的用戶可以添加自定義類型的節點(我們稱之爲「播放器」),但無法發佈它們。實際上,他們需要在發佈之前進行調節。一旦管理員/管理員發佈了他們,我想將所有者/發佈者更改爲相關的管理員/管理員。這是爲了讓用戶無法編輯它們,因此可以跟蹤誰批准他們等。更改Drupal中發佈節點上的所有者
我該如何解決這個問題?我認爲它可能涉及操作/規則/工作流程/工作流程ng等,但我已經看過每一個,似乎無法弄清楚如何使其工作!
另一種選擇是使用hook_link()編寫包含'批准'鏈接的短模塊。指向鏈接到菜單回調的點,該菜單回調將節點的所有權從當前用戶更改爲單擊「批准」鏈接的用戶。
它可能是很好的,乾淨的解決方法,但需要一點Drupal知識。但是,如果您在irc.freenode.net上的#drupal IRC頻道中詢問某人,他們可以向您展示如何開始使用,甚至可以將其作爲您貢獻的模塊進行編碼。
您可以在編輯播放器節點時手動執行此操作。最後有一組兩個設置,您可以在其中更改節點創建者和創建時間。
或者,您可以授予非管理員用戶創建節點的權限,但刪除其編輯這些節點的權限。可能會工作,但可能會讓這些用戶感到痛苦。
只需添加一些信息 - BrainV幫助我爲自定義模塊開發了以下代碼 - 在此處稱爲publishtrigger。我想確認按鈕來發布播放器的節點,然後將其分配給「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);
}
我想我需要的是一個自定義的觸發條件(當玩家節點從未發佈到發佈),然後我可以調用一個Action來更改所有者。我只需要弄清楚如何製作該觸發器! – x3ja 2009-08-28 11:20:25