转:http://www.it165.net/design/html/201302/1734.html
项目要求让普通用户看不到“网站操作”,为了解决该问题,我找了好几篇博客,但都是sharepoint2007,按照sharepoint designer签出,签入,审批,发布。可能是sharepoint2007和sharepoint2010的区别,发布后我的首页直接出错。之后还原了v4.master的版本也无济于事。只好将sharepoint还原,甚是麻烦。
于是想到直接修改v4.master文件,修改之前备份,这样即使出错只修改将备份文件还原就可以了,不需要用到sharepoint designer签入,签出,审批,发布。
搜索v4.master,有两个文件,一个是在C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATELAYOUTS目录下,另一个是在C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATEGLOBAL下,仔细分析v4.master文件,不难发现SharePoint:SPRibbon这样的sharepoint控件拥有权限控制,权限格式如下:PermissionsString="EditListItems, AddAndCustomizePages" PermissionMode="All" 顾名思义,PermissionsString就是哪些权限拥有可见权限,PermissionMode就是权限模式。
我们将SharePoint:SPRibbon修改成如下:
1.
?
2.
<
SharePoint:SPRibbon
3.
runat
=
"server"
4.
PlaceholderElementId
=
"RibbonContainer"
5.
CssFile
=
""
6.
FixedPositioningEnabled
=
"true"
7.
PermissionsString
=
"EditListItems,
AddAndCustomizePages"
8.
PermissionMode
=
"All"
>
这样一般权限的用户就看不到ribbon了。
但“网站操作”还在,我们想办法隐藏,于是想当然
1.
<
SharePoint:SiteActions
runat
=
"server"
accesskey="<%$Resources:wss,tb_SiteActions_AK%>" id="SiteActionsMenuMain"
2.
PrefixHtml=""
3.
SuffixHtml=""
4.
MenuNotVisibleHtml=" "
5.
PermissionsString="EditListItems, AddAndCustomizePages"<
BR
>
<
BR
>PermissionMode="All">
结果页面报错,出错原因是SharePoint:SiteActions没有PermissionsString属性。 www.it165.net
于是Google了一番,找到将SharePoint:SiteActions和span放在<Sharepoint:SPSecurityTrimmedControl即可。
01.
<
Sharepoint:SPSecurityTrimmedControl
ID
=
"SPSecurityTrimmedControl2"
runat
=
"server"
PermissionsString
=
"EditListItems, AddAndCustomizePages"
02.
PermissionMode
=
"All"
>
03.
<
span
class
=
"ms-siteactionsmenu"
id
=
"siteactiontd"
>
04.
<
SharePoint:SiteActions
runat
=
"server"
accesskey="<%$Resources:wss,tb_SiteActions_AK%>" id="SiteActionsMenuMain"
05.
PrefixHtml=""
06.
SuffixHtml=""
07.
MenuNotVisibleHtml=" "
08.
>
09.
........
10.
11.
</
SharePoint:SiteActions
></
span
>
12.
</
Sharepoint:SPSecurityTrimmedControl
>