As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
<#if user.isAdmin> <div class="toolbar"> <a href="#" id="${args.htmlid}-createSite-button" class="theme-color-1">${msg("link.createSite")}</a> </div> </#if>
If you simply want to prevent the Create Site-link from being shown you could disable it in the file my-sites.get.html.ftl.You should be able to use something like this to enable it for Admin users only:<#if user.isAdmin> <div class="toolbar"> <a href="#" id="${args.htmlid}-createSite-button" class="theme-color-1">${msg("link.createSite")}</a> </div> </#if> (That's also how the Administration link in the header is shown/hidden.)However, this will not disable the functionality itself, merely the link.
<#if !isGuest> <#if user.isAdmin> <ul class="create-site-menuitem"> <li> <a href="#" onclick="thisHeader.showCreateSite(); return false;">${msg("header.sites.createSite")}</a> </li> </ul> </#if> </#if>
<#if user.isAdmin> <div class="detail-list-item"> <h4 class="theme-color-2">${msg("header.customiseDashboard")}</h4> <div>${msg("text.customiseDashboard")}</div> <div><a href="${url.context}/page/customise-user-dashboard" class="theme-color-2">${msg("link.customiseDashboard")}</a></div> </div> <div class="detail-list-item last-item"> <h4 class="theme-color-2">${msg("header.createSite")}</h4> <div>${msg("text.createSite")}</div> <div><a id="${args.htmlid}-createSite-button" href="#" class="theme-color-2">${msg("link.createSite")}</a></div> </div> <#else> <div class="detail-list-item last-item"> <h4 class="theme-color-2">${msg("header.customiseDashboard")}</h4> <div>${msg("text.customiseDashboard")}</div> <div><a href="${url.context}/page/customise-user-dashboard" class="theme-color-2">${msg("link.customiseDashboard")}</a></div> </div>
If you simply want to prevent the Create Site-link from being shown you could disable it in the file my-sites.get.html.ftl.to remove it from the Getting started dashlet edit user-welcome.get.html.ftl , something like : <#if user.isAdmin> <div class="detail-list-item"> <h4 class="theme-color-2">${msg("header.customiseDashboard")}</h4> <div>${msg("text.customiseDashboard")}</div> <div><a href="${url.context}/page/customise-user-dashboard" class="theme-color-2">${msg("link.customiseDashboard")}</a></div> </div> <div class="detail-list-item last-item"> <h4 class="theme-color-2">${msg("header.createSite")}</h4> <div>${msg("text.createSite")}</div> <div><a id="${args.htmlid}-createSite-button" href="#" class="theme-color-2">${msg("link.createSite")}</a></div> </div> <#else> <div class="detail-list-item last-item"> <h4 class="theme-color-2">${msg("header.customiseDashboard")}</h4> <div>${msg("text.customiseDashboard")}</div> <div><a href="${url.context}/page/customise-user-dashboard" class="theme-color-2">${msg("link.customiseDashboard")}</a></div> </div>
Use the extensions mechanism*, that's what it's there for.* shared/classes/alfresco/extension for the alfresco.warshared/classes/alfresco/web-extension for the share.warThanks,Mike
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].displayName == group || groups[i].displayName == "ALFRESCO_ADMINISTRATORS"){ return true; // found group }else{ mygroup = mygroups+groups[i].displayName; } } return false; } else return false; }
var createSiteVisible = userHasGroup(user.name, 'YOUR_GROUP_NAME'); model.createSiteVisible = createSiteVisible;
<#if !user.isGuest> <ul class="create-site-menuitem"> <li> <a href="#" onclick="thisHeader.showCreateSite(); return false;">${msg("header.sites.createSite")}</a> </li> </ul> </#if>
<#if createSiteVisible> <ul class="create-site-menuitem"> <li> <a href="#" onclick="thisHeader.showCreateSite(); return false;">${msg("header.sites.createSite")}</a> </li> </ul> </#if>
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 mygroup; } else return false; }
var createSiteVisible = userHasGroup(user.name, 'CAN_CREATE_SITE'); model.createSiteVisible = createSiteVisible;
<ul class="create-site-menuitem"> <li> <span><a href="#" onclick="${jsid}.showCreateSite(); return false;">${msg("label.create-site")}</a></span> </li> </ul>
<#if createSiteVisible> <ul class="create-site-menuitem"> <li> <span><a href="#" onclick="${jsid}.showCreateSite(); return false;">${msg("label.create-site")}</a></span> </li> </ul> </#if>
<#if user.isAdmin> <ul class="create-site-menuitem"> <li> <span><a href="#" onclick='Alfresco.util.ComponentManager.get("${id_js}").showCreateSite(); return false;'>${msg("label.create-site")}</a></span> </li> </ul> </#if> </div>
<item type="js" id="sites" permission="admin">Alfresco.module.Sites</item>
<#if user.isAdmin> <span class="align-right yui-button-align"> <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> </span> </#if>
Correctly, with official solution, the "Create Site" link does not disappear. There is also no dedicated error message to tell you what happened. Thus, the better solution is to wrap the code just in below way.Edit file: /opt/alfresco-4.0.b/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/dashlets/my-sites.get.html.ftl <#if user.isAdmin> <span class="align-right yui-button-align"> <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> </span> </#if> Note: Change takes effect only after restarting alfresco server
function main() { createSite = false var result = remote.call("/api/people/" + stringUtils.urlEncode(user.name) + "?groups=true"); if (result.status == 200) { var i; // Create javascript objects from the server response // This is the User and it also contains all groups. var userValue = eval('(' + result + ')'); if (userValue.groups.length != 0) { for (i = 0; i < userValue.groups.length; i++) { if (userValue.groups[i].itemName == "GROUP_ALFRESCO_ADMINISTRATORS") createSite = true; } } } // Check for IMAP server status var result = remote.call("/imap/servstatus"), imapServerEnabled = (result.status == 200 && result == "enabled"); // Prepare the model for the template model.imapServerEnabled = imapServerEnabled; model.createSite = createSite; } main();