How to define a custom condition or permission for use in alfresco share global header?

StackOverflow https://stackoverflow.com/questions/20997255

  •  25-09-2022
  •  | 
  •  

Domanda

The following is an excerpt for the share global header:

<container-group id="tools" permission="admin">  <== Like this
                        <item type="link" id="application">/console/admin-console/application</item>
                        <item type="link" id="groups">/console/admin-console/groups</item>
                        <item type="link" id="replication-jobs" condition="!conditionEditionTeam">/console/admin-console/replication-jobs
                        </item>
                        <item type="link" id="repository">/console/admin-console/repository</item>
                        <item type="link" id="trashcan">/console/admin-console/trashcan</item>
                        <item type="link" id="users">/console/admin-console/users</item>
                        <item type="link" id="more">/console/admin-console/</item>
                    </container-group>
                </item>
            </app-items>
            <user-items>
                <item type="container" id="user" icon="" description="">
                    <container-group id="usermenu" label="">
                        <item type="user" id="status">{userprofilepage}</item>
                        <item type="link" id="my-profile">{userprofilepage}</item>
                        <item type="link" id="change-password" condition="user.capabilities.isMutable">/user/change-password
                        </item>
                        <item type="link" id="logout" condition="!context.externalAuthentication">/dologout</item> <== Or Like this
                    </container-group>
                </item>

I'd like to know how to define my own condition or how to leverage permission against an arbitral group for another set of menu items I want to add to it. Is this possible?

Edit: I found this share wiki for 3.4 but not sure it's still relevant to my installation (4.2.c)

È stato utile?

Soluzione

I guess this solution is a little bit messy but at least it gets the job done. Maybe you can add the check-fct in something like "myOwnChecks.inc.ftl" if you need them in other places as well (at least I used them in several other places as well).

The js-controller in the webscript used (header.get.*) for the header component can be found at ../alfresco/site-webscripts/org/alfresco/components/header/header.get.js. Within the js-controller (header.get.js) is the function "getHeader()" where the variable "permissions" is set for the model. This is the only file you need to change, you can check out header.inc.ftl if you'd like to see how it's used to apply permissions.

/**
 * Customizable Header
 */
function getHeader()
{
  // Array of tokenised values for use in i18n messages
  model.labelTokens = [ user.name || "", user.firstName || "", user.lastName || "", user.fullName || ""];
  model.permissions =
  {
    guest: user.isGuest,
    admin: user.isAdmin
  };
}

Add the additional entries you'd later like to use in the share-conf (it's a simple share-webscript, remote-calls to alfresco are possible of course), f.e.

model.permissions =
{
  guest: user.isGuest,
  admin: user.isAdmin,
  adminGrp: isInAdminGrp()
};

And then a simple permission="adminGrp" in share-conf should suffice.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top