Drupal 是一套開放源碼的內容管理平台,擁有多種實用的功能,可以用來建置從個人網誌到大型網路社群等各種類型的網站,例如華納唱片、紐約觀察報、Fast Company、Popular Science、SonyBMG、富比士、哈佛大學等網站,或是個人部落格(Tim Berners-Lee)、播客網站(TWIT.tv)、線上社群(SpreadFireFox.com)。
Drupal 是一套開放源碼的內容管理平台,擁有多種實用的功能,可以用來建置從個人網誌到大型網路社群等各種類型的網站,例如華納唱片、紐約觀察報、Fast Company、Popular Science、SonyBMG、富比士、哈佛大學等網站,或是個人部落格(Tim Berners-Lee)、播客網站(TWIT.tv)、線上社群(SpreadFireFox.com)。
Re: 權限設定問題
這是我一直以來的需求,看看這個模組吧
from open mind to open source~
http://drupal.org/project/override_node_options
--
Re: 權限設定問題
謝謝 jimmy 的回覆, 可惜我試的是 drupal 6.2
Re: 權限設定問題
如果有給 roleA "administer nodes" 權限,
即使 edit any story content 沒有打勾(也就是不想讓他可以去修改其他角色所發的文章)
,但我發現 roleA 還是可以針對任意文章做任何的動作
現在我在考慮是否要改用 5.7版
Re:
6.2還沒摸過
不知道詳細的語法上是否有更動
你可以試試看以下這種做法是否可行
在 form_alter 裡面去修改 node edit 的表單
把 發佈選項 部分的 access 的設定改掉
原本的是 '#access' => user_access('administer nodes'), 所以必須要開 'administer nodes' 權限才看的到
如果把 '#access' 改成 TRUE 就應該不管任何權限都看的到了
<?php
function mymodule_form_alter($form_id, &$form){
if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
$form['options']['#access'] = TRUE;
}
}
?>
以上是根據 5.7 的node 模組
在 6.x 下面可能得去查一下 node 模組裡的 function node_form
看看 element 的結構以及權限設定是否有更動過
Re: 權限設定問題
查了一下 6.x 的 API
修訂版本(Revision information)的部分
<?php
if (!empty($node->revision) || user_access('administer nodes')) {
$form['revision_information'] = array(
'#type' => 'fieldset',
'#title' => t('Revision information'),
'#collapsible' => TRUE,
// Collapsed by default when "Create new revision" is unchecked
'#collapsed' => !$node->revision,
'#weight' => 20,
);
$form['revision_information']['revision'] = array(
'#access' => user_access('administer nodes'),
'#type' => 'checkbox',
'#title' => t('Create new revision'),
'#default_value' => $node->revision,
);
$form['revision_information']['log'] = array(
'#type' => 'textarea',
'#title' => t('Log message'),
'#rows' => 2,
'#description' => t('An explanation of the additions or updates being made to help other authors understand your motivations.'),
);
}
?>
發佈選項(Publishing options)的部分
<?php
$form['options'] = array(
'#type' => 'fieldset',
'#access' => user_access('administer nodes'), //這裡必須改為 TRUE 來開放權限 或是你可以自訂一個 perm 來控制
'#title' => t('Publishing options'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => 25,
);
$form['options']['status'] = array(
'#type' => 'checkbox',
'#title' => t('Published'),
'#default_value' => $node->status,
);
$form['options']['promote'] = array(
'#type' => 'checkbox',
'#title' => t('Promoted to front page'),
'#default_value' => $node->promote,
);
$form['options']['sticky'] = array(
'#type' => 'checkbox',
'#title' => t('Sticky at top of lists'),
'#default_value' => $node->sticky,
);
?>
看了一下 6.x 的版本
發佈選項的部分做法沒變
但是修訂版本的選項被從發佈選項中獨立出來
而且用 if (!empty($node->revision) || user_access('administer nodes')) 作了一個判斷
這部分沒辦法用 form_alter 來作修改
複製一份 修訂版本 的 elements 把判斷的部分拿掉
放到 form_alter 內試試
$form 裡同樣 id 的 elements 應該會覆蓋過去 我想是不會產生重複出現的問題
<?php
$form['revision_information'] = array(
'#type' => 'fieldset',
'#title' => t('Revision information'),
'#collapsible' => TRUE,
// Collapsed by default when "Create new revision" is unchecked
'#collapsed' => !$node->revision,
'#weight' => 20,
);
$form['revision_information']['revision'] = array(
'#access' => user_access('administer nodes'), //這裡必須改為 TRUE 來開放權限 或是你可以自訂一個 perm 來控制
'#type' => 'checkbox',
'#title' => t('Create new revision'),
'#default_value' => $node->revision,
);
$form['revision_information']['log'] = array(
'#type' => 'textarea',
'#title' => t('Log message'),
'#rows' => 2,
'#description' => t('An explanation of the additions or updates being made to help other authors understand your motivations.'),
);
?>
Re: 權限設定問題
hom...good job!!