Hello,
I'm back with a solution even if I'm not sure if it's the best. Any way that solved my problem.
I modified the method ObjectRenderer_renderCellAdd of object-finder.js to check if the user is the document coordinator and if there is no other active workflow linked to the document.
Instead of :
<javascript>
elCell.innerHTML = '<a id="' + containerId + '" href="#" ' + style + ' class="add-item add-' + scope.eventGroup + '" title="' + scope.msg("form.control.object-picker.add-item") + '" tabindex="0"><span class="addIcon"> </span></a>';
</javascript>
I put :
<javascript>
var showSelectLink = true;
if(oRecord.getData("type") == "cm:content"){
showSelectLink = false;
//Checking if the document is already in an other active worflow
var xmlHttp = new XMLHttpRequest();
var url = window.location.href;
var arr = url.split("/");
xmlHttp.open( "GET", (arr[0] + "//" + arr[2]).concat("/alfresco/s/api/node/").concat((oRecord.getData("nodeRef")).replace(":/","")).concat("/workflow-instances"), false );
xmlHttp.send( null );
var json = JSON.parse(xmlHttp.responseText);
if(json.data.length == 0){
//Checking if the logged on user is the document coordinator
xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", (arr[0] + "//" + arr[2]).concat("/alfresco/s/slingshot/doclib/permissions/").concat((oRecord.getData("nodeRef")).replace(":/","")), false );
xmlHttp.send( null );
var json = JSON.parse(xmlHttp.responseText);
var hasDirectPermission = false;
//Direct permission
if(json.direct.length != 0){
var permission;
for(var index = 0; index < json.direct.length; index++){
permission = json.direct[index];
if(permission.role == "Coordinator"){
showSelectLink = true;
hasDirectPermission = true;
break;
}
}
}
//Inherited Permission
if(!hasDirectPermission && json.inherited.length != 0){
var permission;
for(var index = 0; index < json.inherited.length; index++){
permission = json.inherited[index];
if(permission.role == "Coordinator"){
showSelectLink = true;
break;
}
}
}
}
}
if(showSelectLink){
elCell.innerHTML = '<a id="' + containerId + '" href="#" ' + style + ' class="add-item add-' + scope.eventGroup + '" title="' + scope.msg("form.control.object-picker.add-item") + '" tabindex="0"><span class="addIcon"> </span></a>';
}
</javascript>
Regards,