detailsToolC = ToolFactory.createToolController(getWindowControl());
detailsToolC.addControllerListener(this);
isNewController = true;
}
// init handler details
RepositoryHandler handler = RepositoryHandlerFactory.getInstance().getRepositoryHandler(repositoryEntry);
if (isNewController) {
detailsToolC.addHeader(translate("tools.details.header"));
detailsToolC.addLink(ACTION_LAUNCH, translate("details.launch"), TOOL_LAUNCH, null);
}
detailsToolC.setEnabled(TOOL_LAUNCH, checkIsRepositoryEntryLaunchable(ureq));
if (!isGuestOnly) {
if (isNewController) {
//mark as download link
detailsToolC.addLink(ACTION_DOWNLOAD, translate("details.download"), TOOL_DOWNLOAD, null, true);
detailsToolC.addLink(ACTION_BOOKMARK, translate("details.bookmark"), TOOL_BOOKMARK, null);
}
boolean canDownload = repositoryEntry.getCanDownload() && handler.supportsDownload();
// disable download for courses if not author or owner
if (repositoryEntry.getOlatResource().getResourceableTypeName().equals(CourseModule.getCourseTypeName())
&& !(isOwner || isAuthor)) canDownload = false;
// always enable download for owners
if (isOwner && handler.supportsDownload()) canDownload = true;
detailsToolC.setEnabled(TOOL_DOWNLOAD, canDownload);
boolean canBookmark = true;
if (BookmarkManager.getInstance().isResourceableBookmarked(ureq.getIdentity(), repositoryEntry) || !repositoryEntry.getCanLaunch())
canBookmark = false;
detailsToolC.setEnabled(TOOL_BOOKMARK, canBookmark);
}
if (isAuthor || isOwner) {
boolean canCopy = repositoryEntry.getCanCopy();
if (isOwner) {
if (isNewController) {
detailsToolC.addLink(ACTION_EDIT, translate("details.openeditor"), TOOL_EDIT, null);
detailsToolC.addLink(ACTION_EDITDESC, translate("details.chdesc"), TOOL_CHDESC, null);
detailsToolC.addLink(ACTION_EDITPROP, translate("details.chprop"), TOOL_CHPROP, null);
detailsToolC.addLink(ACTION_ADD_CATALOG, translate("details.catadd"), TOOL_CATALOG, null);
if ((OresHelper.isOfType(repositoryEntry.getOlatResource(), CourseModule.class)) && (!RepositoryManager.getInstance().createRepositoryEntryStatus(repositoryEntry.getStatusCode()).isClosed())) {
detailsToolC.addLink(ACTION_CLOSE_RESSOURCE, translate("details.close.ressoure"), TOOL_CLOSE_RESSOURCE, null);
}
}
// update catalog link
detailsToolC.setEnabled(TOOL_CATALOG, (repositoryEntry.getAccess() >= RepositoryEntry.ACC_USERS));
}
if (isNewController)
detailsToolC.addLink(ACTION_COPY, translate("details.copy"), TOOL_COPY, null);
if (isOwner) {
if (isNewController) {
detailsToolC.addLink(ACTION_DELETE, translate("details.delete"));
detailsToolC.addLink(ACTION_GROUPS, translate("details.groups"));
}
// enable
detailsToolC.setEnabled(TOOL_EDIT, handler.supportsEdit());
detailsToolC.setEnabled(TOOL_CHDESC, true);
detailsToolC.setEnabled(TOOL_CHPROP, true);
canCopy = true;
}
detailsToolC.setEnabled(TOOL_COPY, canCopy);