How to lock attachments from being downloaded

Hello,

Im trying to lock an attachment from being downloaded from the knowledge center. Is this possible in some way? I would need a full lock, nobody except Supervisors could download them

Thank you for your time

Like 0

Like

1 comments

Dear Pablo,

Such task can only be achieved by the means of development in the system.

In the Configuration add a replacing schema of FileDetailV2.

In the schema, you need to:

1. Initialize check of the current user, whether he has system administrator role. This is an ESQ method called in init function.

2. Set the result of ESQ to an attribute, so to use it later in the method check.

3. Override basic addColumnLink method and add two checks: section check and system administrator check.

The example of replacing FileDetailV2 schema is displayed below:

define("FileDetailV2", ["ConfigurationConstants"], function(ConfigurationConstants) {
	return {
 
		attributes: {
			"isSysAdmin": {
				"type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
				"dataValueType": Terrasoft.DataValueType.BOOLEAN,
				"value": false
			}
		},
 
		methods: {
			init: function() {
				this.getUserRights();
				this.callParent(arguments);
			},
			addColumnLink: function(item, column) {
				if (this.parentEntity.EntityName === "KnowledgeBase") {
					if (this.get("isSysAdmin")) {
						this.callParent(arguments);
					}
				} else {
					this.callParent(arguments);
				}
			},
			getUserRights: function() {
				var scope = this;
 
				var currentUser = Terrasoft.SysValue.CURRENT_USER.value;
				var sysAdmins = ConfigurationConstants.SysAdminUnit.Id.SysAdministrators;
				var esq = Ext.create("Terrasoft.EntitySchemaQuery", { rootSchemaName: "SysUserInRole" });
				esq.addColumn("SysRole");
				esq.addColumn("SysUser");
				esq.filters.add("SysUser", Terrasoft.createColumnFilterWithParameter(
					Terrasoft.ComparisonType.EQUAL, "SysUser", currentUser));
				esq.filters.add("SysRole", Terrasoft.createColumnFilterWithParameter(
					Terrasoft.ComparisonType.EQUAL, "SysRole", sysAdmins));
				esq.getEntityCollection(function(response) {
					if (response && response.success) {
						var result = response.collection;
						var isSysAdmin = (result.collection.length !== 0);
						scope.set("isSysAdmin", isSysAdmin);
					}
				}, this);
			}
		}
	};
});

Regards,

Anastasia

Show all comments