在CMS網站中,我們常常需要給不同的角色分配不同的瀏覽權限。在drupal7中,採用分類權限控制法就可以實現此功能。比如:我們設置了“分公司領導”、“分公司中層”、和“分公司員工”等角色,在分類詞彙“分享對象”中設置“分公司領導”、“分公司中層”、“分公司員工”等。如果我們希望角色“分公司領導”可以瀏覽上述全部內容,角色“分公司中層”可以瀏覽“分公司中層”和“分公司員工”分類的內容,角色“分公司員工”只能瀏覽“分公司員工”分類的內容。下面介紹具體的實現方法。
勾選Global下面的default選框,查看、更新、刪除選項都選“D”,Add Tag、View Tag 不勾選。保存。
4、設置“分公司領導”、“分公司中層”、“分公司員工”角色爲可編輯狀態。
編輯“分公司領導”角色的權限:
設置好分享對象“分公司領導”的相應權限後,再依次增加分享對象“分公司中層”和“分公司員工”並設置好相應的權限。
至此,完成了角色“分公司領導”的分類訪問授權。如果登錄用戶的角色是“分公司領導”,那麼他就可以瀏覽“分公司領導”、“分公司中層”、“分公司員工”三個分類下面的內容了。
其他角色的分類權限設置照此辦理。
5、應用案例
在新增文章時,選擇相應的分享對象,文章保存後,會有分享對象的術語列示,點擊可鏈接到相關分類的頁面列表。當然,對無權用戶,這個標籤和鏈接都是不可見的。假如用戶不屬於“分公司領導”角色,新建一篇文章,選擇“分享對象”爲“分公司領導”:
以用戶hyh登錄。用戶hyh屬於“分公司領導”角色。那麼他可以看到這篇文章和相應的分類標籤:
點擊“分享對象”下的“分公司領導”鏈接,就可以瀏覽“分公司領導”分類下的文章列表:
現在以“gechene”用戶登錄。因爲““gechene”不屬於“分公司領導”角色,他看不到上面的頁面。
6、下面是Taxonomy Access Control 的英文用法說明。
Using the Taxonomy Access Control ModuleHere's the example we're going to use in this tutorial.
Here's how we use Taxonomy Access Control to solve this problem.
You'll now see the main Taxonomy Access Control page. Here's how to understand the page:
First, let's add the tags:
Now let's look across the top of the page:
Here are 5 new permissions that Drupal doesn't have by default:
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:
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. Look back up to the image at the start of this tutorial. Here's how that screen now appears to anonymous users. |