Alfresco5 modify header menu

Alfresco 5 use dojo to create his header menu therefore you have to modify the javascript that create that header menu, the header menu is create by an Array that you can find on this directory

/opt/alfresco-5.0.b/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/share/imports/share-header.lib.js

 

In this code you have to find the part of code with title CONSTRUCT MENU BAR LEFT the array that create the menu bar is appItems, isert inside everything you want see in header menu.
If you want that visible just to admin, just add the if condition like this if(user.isAdmin).

Below and example of code to show just repository tab on header menu for normal user and the original header for the administrator

/* *********************************************************************************
* *
* CONSTRUCT LEFT MENU BAR (NEW) *
* *
***********************************************************************************/
/*
* This function generates the "app items" to include in the header. In actual fact this just refers to the
* items that are rendered on the left-hand-side of the screen but for historical reasons (and because of the
* default values) can be regarded as application items.
*/
function generateAppItems() {
var appItems = [ {
id: "HEADER_REPOSITORY",
name: "alfresco/menus/AlfMenuBarItem",
config: {
id: "HEADER_REPOSITORY",
label: "header.menu.repository.label",
targetUrl: "repository"
}
}

];
if (user.isAdmin )
{
appItems.push( {
id: "HEADER_HOME",
name: "alfresco/menus/AlfMenuBarItem",
config: {
id: "HEADER_HOME",
label: "header.menu.home.label",
targetUrl: "user/" + encodeURIComponent(user.name) + "/dashboard"
}
},
{
id: "HEADER_MY_FILES",
name: "alfresco/menus/AlfMenuBarItem",
config: {
id: "HEADER_MY_FILES",
label: "header.menu.myfiles.label",
targetUrl: "context/mine/myfiles"
}
},
{
id: "HEADER_SHARED_FILES",
name: "alfresco/menus/AlfMenuBarItem",
config: {
id: "HEADER_SHARED_FILES",
label: "header.menu.shared.label",
targetUrl: "context/shared/sharedfiles"
}
},
{
id: "HEADER_SITES_MENU",
name: "alfresco/header/AlfSitesMenu",
config: {
id: "HEADER_SITES_MENU",
label: "header.menu.sites.label",
currentSite: page.url.templateArgs.site,
currentUser: user.name
}
},
{
id: "HEADER_TASKS",
name: "alfresco/header/AlfMenuBarPopup",
config: {
id: "HEADER_TASKS",
label: "header.menu.tasks.label",
widgets: [
{
name: "alfresco/menus/AlfMenuGroup",
config: {
widgets: [
{
id: "HEADER_MY_TASKS",
name: "alfresco/header/AlfMenuItem",
config:
{
id: "HEADER_MY_TASKS",
label: "header.menu.mytasks.label",
iconClass: "alf-mytasks-icon",
targetUrl: "my-tasks#filter=workflows|active"
}
},
{
id: "HEADER_MY_WORKFLOWS",
name: "alfresco/header/AlfMenuItem",
config:
{
id: "HEADER_MY_WORKFLOWS",
label: "header.menu.myworkflows.label",
iconClass: "alf-myworkflows-icon",
targetUrl: "my-workflows#filter=workflows|active"
}
}
]
}
}
]
}
},
{
id: "HEADER_PEOPLE",
name: "alfresco/menus/AlfMenuBarItem",
config: {
id: "HEADER_PEOPLE",
label: "header.menu.people.label",
targetUrl: "people-finder"
}
});
}
if (user.isAdmin)
{
appItems.push({
id: "HEADER_ADMIN_CONSOLE",
name: "alfresco/menus/AlfMenuBarItem",
config: {
id: "HEADER_ADMIN_CONSOLE",
label: "header.menu.admin.label",
targetUrl: "console/admin-console/application"
}
});
}
else
{
appItems.push({
id: "HEADER_ADMIN_CONSOLE",
name: "alfresco/menus/AlfMenuBarItem",
config: {
id: "HEADER_SITES_CONSOLE",
label: "header.menu.admin.sites.label",
targetUrl: "console/sites-console/manage-sites",
renderFilter: [
{
property: "user.groups.GROUP_SITE_ADMINISTRATORS",
values: [true]
}
]
}
});
}
return appItems;
}

Giuseppe Zagaria