drupal7分類權限控制方法

在CMS網站中,我們常常需要給不同的角色分配不同的瀏覽權限。在drupal7中,採用分類權限控制法就可以實現此功能。比如:我們設置了“分公司領導”、“分公司中層”、和“分公司員工”等角色,在分類詞彙“分享對象”中設置“分公司領導”、“分公司中層”、“分公司員工”等。如果我們希望角色“分公司領導”可以瀏覽上述全部內容,角色“分公司中層”可以瀏覽“分公司中層”和“分公司員工”分類的內容,角色“分公司員工”只能瀏覽“分公司員工”分類的內容。下面介紹具體的實現方法。

1、安裝Taxonomy Access Control模塊並啓用。
2、點擊配置》用戶》Taxonomy Access Control。

3、編輯匿名用戶和註冊用戶的角色權限。

勾選Global下面的default選框,查看、更新、刪除選項都選“D”,Add Tag、View Tag 不勾選。保存。



4、設置“分公司領導”、“分公司中層”、“分公司員工”角色爲可編輯狀態。

編輯“分公司領導”角色的權限:


設置好分享對象“分公司領導”的相應權限後,再依次增加分享對象“分公司中層”和“分公司員工”並設置好相應的權限。


至此,完成了角色“分公司領導”的分類訪問授權。如果登錄用戶的角色是“分公司領導”,那麼他就可以瀏覽“分公司領導”、“分公司中層”、“分公司員工”三個分類下面的內容了。

其他角色的分類權限設置照此辦理。

5、應用案例

在新增文章時,選擇相應的分享對象,文章保存後,會有分享對象的術語列示,點擊可鏈接到相關分類的頁面列表。當然,對無權用戶,這個標籤和鏈接都是不可見的。假如用戶不屬於“分公司領導”角色,新建一篇文章,選擇“分享對象”爲“分公司領導”:


以用戶hyh登錄。用戶hyh屬於“分公司領導”角色。那麼他可以看到這篇文章和相應的分類標籤:


點擊“分享對象”下的“分公司領導”鏈接,就可以瀏覽“分公司領導”分類下的文章列表:



現在以“gechene”用戶登錄。因爲“gechene”不屬於“分公司領導”角色,他看不到上面的頁面。

6、下面是Taxonomy Access Control 的英文用法說明。

Using the Taxonomy Access Control Module

Here's the example we're going to use in this tutorial.
  • On this screen we have 5 content items, all of the same content type.
  • Each content item is tagged with the appropriate state. For example, San Francisco is tagged with "California".
  • We want to deny anonymous users the ability to view items from some states.
media_1355778945289.png
Here's how we use Taxonomy Access Control to solve this problem.
media_1355777813695.png
media_1355777829342.png
  • You'll see a message saying, The content access permissions have been rebuilt.
  • Go to Configuration > Taxonomy Access Control.
  • You'll see that you have options for each user role. Click "edit access" rules next to anonymous user.
media_1355778312806.png

You'll now see the main Taxonomy Access Control page. Here's how to understand the page:

  • You add the tags on the left.
  • You look for the permissions across the top.
media_1355778345432.png

First, let's add the tags:

  • Under New, choose a tag.
  • Click Add.
  • Repeat until you've chosen all the tags that you want to control access for.
media_1355778451527.png
 
Now let's look across the top of the page:
media_1355778577251.png
Here are 5 new permissions that Drupal doesn't have by default:
  • View: can the user see nodes with this term?
  • Update: can the user edit node with this term?
  • Delete: can the user delete nodes with this term?
  • Add: can the user add this term to a node?
  • View: can the user see the term when looking at a node?

Now that we've seen both the left and the top of the page, we can start to apply permissions.

For each permssion, you choose the setting for each tag. Here's what the labels A, I, D mean:

  • A: people in this user role (in this case, anonymous) have this permission (in this case, View)
  • I: people in this user role have the same permissions as the default setting above
  • D: people in this user role do not have this permission.

So, if we the permissions as in the image below, anonymous users can view content tagged with Texas and Washington but they can't view content tagged with California or Georgia.

media_1355778552743.png

Look back up to the image at the start of this tutorial. Here's how that screen now appears to anonymous users.

 
media_1355779013696.png
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章