08-16-2017 04:36 AM
08-24-2017 07:43 AM
Here is what you need to disable both download buttons for everyone:
If you want to disable it just for a Consumer you can use an evaluator to check group membership.
08-17-2017 12:32 AM
hi, have you resolved this problem? I have same problem too.
08-17-2017 04:28 AM
Can you please look at the github project link ?
GitHub - muralidharand/alfresco-disable-enable-download-action
08-17-2017 06:15 AM
Interesting project, but it seems it does not remove the options to download from the preview component, neither from the search result.
12-07-2023 12:16 AM
I did my research about alfresco and made a simple documentation. Have a look at the code below:
Find the section for disabling downloads.
#################################################
Alfresco -Installation using docker
#################################################
sudo apt update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo docker -v
#################################################
Result: Docker version 20.10.0, build 7287ab3
#################################################
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo docker-compose -v
#################################################
Result: docker-compose version 1.27.4, build 40524192
#################################################
sudo apt install nodejs
sudo apt install npm
sudo npm install -g yo
sudo npm install --global generator-alfresco-docker-installer
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source ~/.nvm/nvm.sh
nvm install 14
nvm use 14
npm install -g generator-alfresco-docker-installer
yo alfresco-docker-installer
? Which ACS version do you want to use? 7.4
? How may GB RAM are available for Alfresco (8 is minimum required)? 12
? Do you want to use HTTPs for Web Proxy? No
? What is the name of your server? write the name of your server.
? What HTTP port do you want to use (all the services are using the same port)? 80
? Do you want to use FTP (port 2121)? No
? Do you want to use MariaDB instead of PostgreSQL? No
? Are you using different languages (this is the most common scenario)? Yes
? Do you want to create an internal SMTP server? No
? Do you want to create an internal LDAP server? No
? Select the addons to be installed:
? Are you using a Windows host to run Docker? No
? Do you want to use a start script? No
#################################################
Run the command below to start Alfresco app
#################################################
sudo docker-compose up
#################################################
URLs
#################################################
UI (User Interface) : http://sever IP address or Domain name/
Legacy UI (Users and management): http://sever IP address or Domain name/share
Repository (REST API) : http://sever IP address or Domain name/alfresco
#################################################
Legacy UI(users and management) Customization
#################################################
#################################################
How to disable Rightclick
#################################################
Step 1) Stop the alfresco server
Step 2) Edit web-preview.get.html.ftl file found in the directory below
/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/preview
to contain a javascript code that disable rightclick;
<script>
document.addEventListener('contextmenu', function (e) {
e.preventDefault();
// You can add any additional code here if needed
});
</script>
The file should finaly look as shown below;
<@markup id="html">
<@uniqueIdDiv>
<#if node??>
<#assign el=args.htmlid?html>
<div id="${el}-body" class="web-preview">
<div id="${el}-previewer-div" class="previewer">
<div class="message"></div>
</div>
</div>
<script>
document.addEventListener('contextmenu', function (e) {
e.preventDefault();
});
</script>
</#if>
</@>
</@markup>
Step 3) Save and restart the servver
#####################################################
How to Disable the top right corner Download button
#####################################################
Step 1) Stop alfresco server
Step 2) Create an XML file called hide-download-pdf.xml under
/tomcat/shared/classes/alfresco/web-extension/site-data/extension:
<extension>
<modules>
<module>
<id>Hide Download Buttons</id>
<auto-deploy>true</auto-deploy>
<customizations>
<customization>
<targetPackageRoot>org.alfresco</targetPackageRoot>
<sourcePackageRoot>com.someco</sourcePackageRoot>
</customization>
</customizations>
</module>
</modules>
</extension>
Step 3) Create a file node-header.get.js with the following under
/tomcat/shared/classes/alfresco/web-extension/site-webscripts/com/someco/components/node-details
<import resource="classpath:/alfresco/templates/org/alfresco/import/alfresco-util.js">
var nodeDetails = AlfrescoUtil.getNodeDetails(model.nodeRef, model.site, null, model.libraryRoot);
var count = nodeDetails.item.node.properties["cm:autoVersion"];
if (count != undefined)
{
model.showDownload = "false";
}
Step 4) Restart alfresco server.
Go to a file in Alfresco -> Click Manage Aspects from the details options -> add cm:versionable aspect -> Hit Apply changes. You will see that the Download button will disappear
######################################################################
How to Disable the download button at the center, on top of the file
######################################################################
Step 1) Stop the Alfresco server
Step 2) Edit the pdfjs.get.js file under
/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/modules/preview
by commenting the section for download as shown:
{
type: "separator",
useWrapper: true,
wrapperClassName: "maximizebuttonSep"
},
// {
// id: "download",
// type: "button",
// icon: "components/documentlibrary/actions/document-download-16.png",
// label: msg.get("button.download"),
// title: msg.get("button.download")
// },
{
id: "link",
type: "button",
icon: "components/images/link-16.png",
title: msg.get("button.link"),
useWrapper: true,
wrapperClassName: "linkbutton"
},
Step 3) Save and restart the servver.
###############################################################################################
How to Disable Folder Download, Document Download, View document in browser and Edit offline.
###############################################################################################
Step 1) Stop the Alfresco server
Step 2) Edit the share-documentlibrary-config.xml file under
/tomcat/webapps/share/WEB-INF/classes/alfresco
by commenting the section(s):
##############################################################################################
(a) responsible for folder download as shown:
##############################################################################################
<!-- Download folder -->
<!--
<action id="folder-download" type="javascript" label="actions.folder.download" icon="document-download">
<param name="function">onActionFolderDownload</param>
</action>
-->
###############################################################################################
(b) responsible for document download as shown:
###############################################################################################
<!-- Download document -->
<!--
<action id="document-download" type="link" label="actions.document.download">
<param name="href">{downloadUrl}</param>
<param name="target">_blank</param>
<evaluator>evaluator.doclib.action.downloadBrowser</evaluator>
<evaluator>evaluator.doclib.action.hasContent</evaluator>
</action>
-->
###############################################################################################
(c) responsible for View document in browser found under <actionGroup id="document-details">
as shown:
###############################################################################################
<!--
<action index="110" id="document-view-content" subgroup="10" appendEvaluators="true">
<evaluator>evaluator.doclib.action.DocumentEnableInSmartFolder</evaluator>
</action>
-->
#################################################################################################
(d) responsible for Edit offline found under <actionGroup id="document-details">
as shown:
#################################################################################################
<!-- Edit offline -->
<!--
<action id="document-edit-offline" type="javascript" label="actions.document.edit-offline">
<param name="function">onActionEditOffline</param>
<permissions>
<permission allow="true">Write</permission>
</permissions>
<evaluator>evaluator.doclib.action.offlineEdit</evaluator>
<evaluator>evaluator.doclib.action.hasContent</evaluator>
<evaluator negate="true">evaluator.doclib.action.notEditable</evaluator>
</action>
-->
<!--
<action index="360" id="document-edit-offline" subgroup="30" appendEvaluators="true">
<evaluator>evaluator.doclib.action.DocumentEnableInSmartFolder</evaluator>
</action>
-->
Step 3) Save and restart the servver
####################################################################################################
How to hide the Download icon at the Version History section
####################################################################################################
Stop the Alfresco server
Open the document-versions.css file under the path below;
/usr/local/tomcat/webapps/share/components/document-details
Locate the section with the following code;
.document-versions .actions a.download
{
background-image: url(images/document-download-16.png);
}
now delete the entire line of code that starts with background-image so that it finally looks like this;
.document-versions .actions a.download
{
}
Save and restart the servver
#################################################################################
UI Customization
#################################################################################
#################################################################################
Disable rightclick on the UI
#################################################################################
Stop the Alfresco server
Open the html file in the path below;
usr/share/nginx/html/index.html
Insert this javaScript code;
<script>
document.addEventListener('contextmenu', function (event) {
event.preventDefault();
});
</script>
Save and restart the server
########################################################################################################
To disable the offline editting, print and download buttons, open the main.js file in the path below;
/usr/share/nginx/html/main.js
########################################################################################################
########################################################################################################
Disable offline editing
########################################################################################################
Stop the Alfresco server
########################################################################################################
Inside the main.js file, look for a section that contains the following path comment;
/toggle-edit-offline.components.ts
and comment the line that contains the DownloadNodesAction as shown below;
########################################################################################################
toggleLock(node) {
var _this2 = this;
return (0,_home_runner_work_alfresco_content_app_alfresco_content_app_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__["default"])(function* () {
const id = node.entry.nodeId || node.entry.id;
if ((0,_alfresco_aca_shared__WEBPACK_IMPORTED_MODULE_2__.isLocked)(_this2.selection)) {
try {
const response = yield _this2.unlockNode(id);
_this2.update(response?.entry);
_this2.store.dispatch(new _alfresco_aca_shared_store__WEBPACK_IMPORTED_MODULE_1__.EditOfflineAction(_this2.selection));
} catch {
_this2.onUnlockError();
}
} else {
try {
const response = yield _this2.lockNode(id);
_this2.update(response?.entry);
// _this2.store.dispatch(new _alfresco_aca_shared_store__WEBPACK_IMPORTED_MODULE_1__.DownloadNodesAction([_this2.selection]));
_this2.store.dispatch(new _alfresco_aca_shared_store__WEBPACK_IMPORTED_MODULE_1__.EditOfflineAction(_this2.selection));
} catch {
_this2.onLockError();
}
}
})();
}
Save and restart the server
############################################################################################
Disable the print button
############################################################################################
Stop the Alfresco server
############################################################################################
Inside the main.js file, look for a section that contains the following path comment;
/node.effects.ts
and comment the following section as shown below;
############################################################################################
printFile(node) {
/* if (node && node.entry) {
// shared and favorite
const id = node.entry.nodeId || node.entry.guid || node.entry.id;
const mimeType = node.entry.content.mimeType;
if (id) {
this.renditionViewer.printFileGeneric(id, mimeType);
}
}
*/
console.log('Printing is disabled.');
}
}
Save and restart the server
##################################################################################################
Disable/Hide the Download button
##################################################################################################
Stop the Alfresco server
##################################################################################################
Inside the main.js file, look for a section that contains the following path comment;
/app.rules.ts
and comment the following section as shown below;
##################################################################################################
function canDownloadSelection(context) {
/* if (!context.selection.isEmpty && _navigation_rules__WEBPACK_IMPORTED_MODULE_0__.isNotTrashcan(context)) {
return context.selection.nodes.every((node) => node.entry && (node.entry.isFile || node.entry.isFolder || !!node.entry.nodeId));
}
*/
return false;
}
Save and restart the server
THE END
Explore our Alfresco products with the links below. Use labels to filter content by product module.