權限設定問題

最近在試用 drupal,準備做為單位的網站用
但在權限上有些問題想請教

目前有一個 role 為 roleA
在 User management 下的 Permissions 那裡只給他建立/編輯 story 的權限
但是當我 administer nodes 拿掉後, RoleA在編輯完要publish時,
沒有 Publishing options及Revision information 的選項,
除非給予 administer nodes , 但如此一來,卻又可以建立/編輯其他 content type

請問, 有什麼方法可以不讓 roleA 只能編輯被指定的 content type,
然後在沒有 administer nodes 權限下, 又能有Publishing options及Revision information 的選項功能
因為我想讓 roleA自己決定要不要把 文章放在 frontpage

謝謝

jimmy 的照片

Re: 權限設定問題

這是我一直以來的需求,看看這個模組吧
http://drupal.org/project/override_node_options
--
from open mind to open source~

ted 的照片

Re: 權限設定問題

謝謝 jimmy 的回覆, 可惜我試的是 drupal 6.2

ted 的照片

Re: 權限設定問題

如果有給 roleA "administer nodes" 權限,
即使 edit any story content 沒有打勾(也就是不想讓他可以去修改其他角色所發的文章)
,但我發現 roleA 還是可以針對任意文章做任何的動作

現在我在考慮是否要改用 5.7版

hom 的照片

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 的結構以及權限設定是否有更動過

hom 的照片

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.'),
    );
?>

charlesc 的照片

Re: 權限設定問題

hom...good job!!