Adding Menu Tab into NAVBAR (for managers only)

Hi dear friends,

I am using ojs 2.4.7 (latest stable version) and I want to add a new menu tab into navbar which would be only visible & accessable to managers and editors, but not others (reviewer & users). This kind of menu is already present in ojs 3, but I couldnot make it in ojs 2. In ojs 3 I found the code below which wont work in ojs 2. The variable $isUserLoggedIn works fine, but I guess the problem is with variable $userRoles. I suspect it is not defined in ojs2. Can anyone help how to make this menu option work?

{if $isUserLoggedIn}
	{if array_intersect(array(ROLE_ID_MANAGER, ROLE_ID_EDITOR, ROLE_ID_ASSISTANT, ROLE_ID_REVIEWER, ROLE_ID_AUTHOR), $userRoles)}
	     <li><a href="{url page="manager"}">{translate key="navigation.management"}</a></li>
	{/if} {* ROLE_ID_MANAGER, ROLE_ID_EDITOR, ROLE_ID_ASSISTANT, ROLE_ID_REVIEWER, ROLE_ID_AUTHOR *}
{/if}{* $isUserLoggedIn *}

*** I cannot use ojs3 beta right now, because I am on shared host server and I cannot do tools/upgrade.php, (I have no access to ssh, only ftp).

Hi @ihlasnobatovich,

That pattern won’t work in the 2.x codebase – the way we handle roles has changed considerably. You can use the Validation class in OJS2, e.g.:

{if Validation::isJournalManager()}
    // It's a journal manager
{/if}

Have a look at the source code for the Validation class for the full list of functions.

Regards,
Alec Smecher
Public Knowledge Project Team

Many thanks @asmecher, the code your provide seems to work fine :slight_smile: