I am on Alfresco 4.2e Community Edition.I am able to restrict site creation for a particular group by modifying the following files.
In public-services-security-context.xml
org.alfresco.service.cmr.site.SiteService.createSite=ACL_METHOD.ROLE_ADMINISTRATOR,ACL_METHOD.GROUP_SITECREATORS
In sites.get.js and mysites.get.js I added this
var createSiteVisible = userHasGroup(user.name, 'SITECREATORS');
model.createSiteVisible = createSiteVisible;
function userHasGroup(username, group) {
var result = remote.call("/api/people/" + stringUtils.urlEncode(username) + "?groups=true");
if (result.status == 200 && result != "{}")
{
var user = eval('(' + result + ')');
var groups = new Array();
groups = user.groups;
var mygroups = "";
for (i=0; i<groups.length; i++)
{
if (groups[i].itemName == "GROUP_"+group || groups[i].itemName == "GROUP_ALFRESCO_ADMINISTRATORS"){
return true; // found group
}else{
mygroup = mygroups+groups[i].displayName;
}
}
return false;
}
else return false;
}
In my-sites.get.html.ftl and sites.get.html.ftl I modified the condition as
<#if createSiteVisible>
<span class="align-right yui-button-align">
<#if showCreateSite>
<span class="first-child">
<a href="#" id="${id}-createSite-button" class="theme-color-1">
<img src="${url.context}/res/components/images/site-16.png" style="vertical-align: text-bottom" />
${msg("link.createSite")}</a>
</span>
</#if>
</span>
</#if>
User is not able to create site now.But still I am getting create site link in header menu. How to hide create site for the users.
!user.isAdmin
refers to admin user. What is the java script to refer a group?. Thank you
Here is a version that removes the link from the header, the dashlet, AND the welcome dashlet (don't forget about that one). Plus, it changes the underlying permissions to prevent circumventing the UI. In my version I restrict the create site capability to members of a "Site Creators" group.
I found a work around for this. First I hided the Create Site from header for everyone except admin. I added the following files.
I created file in shared/classes/alfresco/web-extension/site-data/extension/remove-create-site-extension.xml
and typed
<extension>
<modules>
<module>
<id>Remove create site menu option for non admin users</id>
<version>1.0</version>
<customizations>
<customization>
<targetPackageRoot>org.alfresco.share.header</targetPackageRoot>
<sourcePackageRoot>ingen.header</sourcePackageRoot>
</customization>
<customization>
<targetPackageRoot>org.alfresco.components.dashlets</targetPackageRoot>
<sourcePackageRoot>ingen.dashlets</sourcePackageRoot>
</customization>
</customizations>
</module>
</modules>
</extension>
Then I created file in shared/classes/alfresco/web-extension/site-webscripts/ingen/header/share-header.get.js
and added
//Find the "Sites" menu...
var sitesMenu = widgetUtils.findObject(model.jsonModel, "id", "HEADER_SITES_MENU");
if (sitesMenu != null) {
if (!user.isAdmin) {
sitesMenu.config.showCreateSite = false;
}
}
Then I created file shared/classes/alfresco/web-extension/site-webscripts/ingen/dashlets/my-sites.get.js
if (!user.isAdmin) {
model.showCreateSite = false;
}
来源:https://stackoverflow.com/questions/22531555/how-to-hide-create-site-link-for-particular-user