I followed the steps to disable download of certain file types (basically copy and paste the code base and deleted the specified lines) but it didn't work. Am I missing anything? Below is taken from listattachmentsforspace.vm:
<html>
<head>
<title>$action.getActionName($action.getClass().getName())</title>
</head>
#macro (sortHover $sortByLink)
#if (!($sortBy == $sortByLink))sortHover#end
#end
#applyDecorator("root")
#decoratorParam("helper" $action.helper)
#decoratorParam("context" "space-operations")
#decoratorParam("mode" "view-space-operations")
#applyDecorator ("root")
#decoratorParam ("context" "spacecontentpanel")
#decoratorParam("helper" $action.helper)
#decoratorParam("selection" "space-attachments")
#decoratorParam("selectedSpaceToolsWebItem" "space-attachments")
#requireResource("confluence.web.resources:attachments")
<div class="pagecontent">
#set ($results = $action.paginationSupport.page)
#if (!$results.empty || $textUtil.stringSet($fileExtension) || $labelsCount > 0)
<form name="listattachmentfilter" action="listattachmentsforspace.action" method="POST" class="aui">
<label for="filterByExtension">$action.getText('filter.by.ext'):</label>
<input class="text" type="text" id="filterByExtension" name="fileExtension" value="$generalUtil.htmlEncode($!fileExtension)" size="10">
<label for="filterByLabel">$i18n.getText('filter.by.label'):</label>
<input class="text" type="text" name="labels" id="filterByLabel" value="$generalUtil.htmlEncode($!labels)" size="10" />
<input type="submit" class="aui-button aui-submit" id="filterAttachments" value="$action.getText('filter.name')">
<input type="hidden" name="key" value="$!generalUtil.urlEncode($key)">
</form>
#end
#if (!$results.empty)
#pagination($action.paginationSupport "listattachmentsforspace.action?key=$!generalUtil.urlEncode($key)&startsWith=$!generalUtil.urlEncode($!action.startsWith)&sortBy=$!generalUtil.urlEncode($!sortBy)&fileExtension=$!generalUtil.urlEncode($!fileExtension)&")
<table class="aui tableview attachments">
<thead>
<tr>
<th class="#sortHover("")">#sortLink("" "$req.contextPath/spaces/listattachmentsforspace.action?key=$!generalUtil.urlEncode($space.key)&fileExtension=$!generalUtil.urlEncode($!fileExtension)&sortBy=" $action.getText('columnheading.name'))</th>
<th class="#sortHover("size")">#sortLink("size" "$req.contextPath/spaces/listattachmentsforspace.action?key=$!generalUtil.urlEncode($space.key)&fileExtension=$!generalUtil.urlEncode($!fileExtension)&sortBy=size" $action.getText('columnheading.size'))</th>
<th>$action.getText('creator.name')</th>
<th class="#sortHover("createddate")">#sortLink("createddate" "$req.contextPath/spaces/listattachmentsforspace.action?key=$!generalUtil.urlEncode($space.key)&fileExtension=$!generalUtil.urlEncode($!fileExtension)&sortBy=createddate" $action.getText('columnheading.creation.date'))</th>
<th class="#sortHover("date")">#sortLink("date" "$req.contextPath/spaces/listattachmentsforspace.action?key=$!generalUtil.urlEncode($space.key)&fileExtension=$!generalUtil.urlEncode($!fileExtension)&sortBy=date" $action.getText('space-last-mod-date'))</th>
<th class="labels">$action.getText('labels.name')</th>
<th class="attachedto">$action.getText('attached.to')</th>
</tr>
</thead>
#foreach ($attachment in $results)
#set ($labels = $attachment.labels)
#set ($labelable = $attachment)
<tr id="attachment_$!attachment.id">
#set($disabledDownloads = ['txt', 'html','png','css','jpg','js'])
#set($disabled = false)
#set($attachmentExtension = $attachment.fileExtension)
<tr id="attachment_$!attachment.id">
#foreach($doNotDownload in $disabledDownloads)
#if($attachmentExtension == $doNotDownload)
#set($disabled = true)
#break
#end
#end
#if(!$disabled)
<td><a name="$!generalUtil.urlEncode($!attachment.content.displayTitle)-attachment-$!generalUtil.urlEncode($!attachment.fileName)">#parse ("/pages/includes/attachment_icon.vm")</a> <a href="$req.contextPath$!attachment.downloadPathWithoutVersion">$generalUtil.shortenString($attachment.fileName, 50)</a></td>
#else
<td><a name="$!generalUtil.urlEncode($!attachment.content.displayTitle)-attachment-$!generalUtil.urlEncode($!attachment.fileName)">#parse ("/pages/includes/attachment_icon.vm")</a> $generalUtil.shortenString($attachment.fileName, 50)</td>
#end
<td>$!attachment.niceFileSize</td>
<td>#userLink($!attachment.creator)</td>
<td>$dateFormatter.formatDateTime($!attachment.creationDate)</td>
<td>$dateFormatter.formatDateTime($!attachment.lastModificationDate)</td>
<td>#parse("/labels/labels-editor-content.vm")</td>
<td class="attachedto">#contentLink2 ($!attachment.getContent() true false)</td>
</tr>
#end
</table>
#pagination($action.paginationSupport "listattachmentsforspace.action?key=$!generalUtil.urlEncode($key)&startsWith=$!generalUtil.urlEncode($!action.startsWith)&sortBy=$!generalUtil.urlEncode($!sortBy)&fileExtension=$!generalUtil.urlEncode($!fileExtension)&")
#else
#if ($textUtil.stringSet($fileExtension))
$action.getText('currently.no.attachments.in.space.ending.with.ext', ["$generalUtil.htmlEncode($fileExtension)"])
#if($labelsCount > 1)
$action.getText('currently.no.attachments.also.with.labels', ["$generalUtil.htmlEncode($labels)"])
#elseif($labelsCount == 1)
$action.getText('currently.no.attachments.also.with.label', ["$generalUtil.htmlEncode($labels)"])
#end
#elseif($labelsCount > 1)
$action.getText('currently.no.attachments.in.space.with.labels', ["$generalUtil.htmlEncode($labels)"])
#elseif($labelsCount == 1)
$action.getText('currently.no.attachments.in.space.with.label', ["$generalUtil.htmlEncode($labels)"])
#else
$action.getText('currently.no.attachments.in.space')
#end
#end
</div>
#end
#end
</html>
and from attachments-table.vm:
## Common template for building the attachments table
## When changing this file, check the attachment macro as well.
## Required Parameters:
## * $attachmentHelper - object used to obtain context and previous versions
## * $sortPathPrefixHtml - the url to goto when sorting
## * $showActions - 'true' if actions column is to be displayed
## * $old - 'true' if older versions are to be displayed
<table class="aui tableview attachments">
<tr>
#if ($old == "true")
<th class="expand-column attachment-history"> </th>
#end
<th class="filename-column">#sortLink("name", "${sortPathPrefixHtml}name" $action.getText('name.word'))</th>
<th class="filesize-column">#sortLink("size", "${sortPathPrefixHtml}size" $action.getText('file.size'))</th>
<th class="filecreator-column">$action.getText('creator.name')</th>
<th class="filedate-column">#sortLink("createddate" "${sortPathPrefixHtml}createddate" $action.getText('columnheading.creation.date'))</th>
<th class="labels">$action.getText('labels.name')</th>
<th class="comment">$action.getText('comment.name')</th>
#if ($showActions == "true")
<th class="actions-column"> </th>
#end
</tr>
## Create a dummy Attachment ID, for when there aren't attachment IDs set (e.g. WebDAV)
#set ($dummyAttachmentId = 1)
#foreach( $attachment in $latestVersionsOfAttachments )
#set ($currentAttachmentId = $attachment.id)
#set ($labels = $attachment.labels)
#set ($labelable = $attachment)
## When the attachment ID isn't set (e.g. when we're using WebDAV), assign it an arbitrary number and increment
#if ($currentAttachmentId.intValue() == 0)
#set ($currentAttachmentId = $dummyAttachmentId)
#set ($dummyAttachmentId = $dummyAttachmentId + 1)
#end
#set ($allVersions = $attachmentHelper.getAllVersions($attachment))
<tr id="attachment-$currentAttachmentId" data-attachment-filename="$generalUtil.htmlEncode($attachment.fileName)" #if ($action.highlight.contains($attachment.fileName)) class="attachment-highlight"#end>
#if ($old == "true")
<td class="attachment-history">
#if ($allVersions.size() > 0)
<a href="#" class="icon icon-section-closed" title="$action.getText('show.attachment.history')"></a>
#end
</td>
#end
<td class="filename-column">
#parse ("/pages/includes/attachment_icon.vm")
<!-- <a class="filename" href="$generalUtil.htmlEncode("${req.contextPath}${attachment.downloadPathWithoutVersion}")"
title="$generalUtil.htmlEncodeAndReplaceSpaces($attachment.fileName)">
$generalUtil.htmlEncode($attachment.fileName)
</a>
-->
#set($disabledDownloads = ['txt', 'html', 'png', 'css', 'jpg', 'js'])
#set($disabled = false)
#set($attachmentExtension = $attachment.fileExtension)
#foreach($doNotDownload in $disabledDownloads)
#if($attachmentExtension == $doNotDownload)
#set($disabled = true)
#break
#end
#end
#if(!$disabled) <a class="filename" href="$generalUtil.htmlEncode("${req.contextPath}${attachment.downloadPathWithoutVersion}")" title="$generalUtil.htmlEncodeAndReplaceSpaces($attachment.fileName)" >$generalUtil.htmlEncode($generalUtil.shortenString($attachment.fileName))</a>
#else $generalUtil.htmlEncode($generalUtil.shortenString($attachment.fileName))
#end
</td>
<td>$attachment.niceFileSize</td>
<td class="creator">#userLink($attachment.creator)</td>
<td class="created-date">$action.dateFormatter.formatDateTime($attachment.creationDate)</td>
<td class="labels">#parse("/labels/labels-editor-content.vm")</td>
<td class="comment">
#if ($attachment.comment && $attachment.comment.trim().length() > 0)
$generalUtil.htmlEncode($attachment.comment)
#else
#end
</td>
#if ($showActions == "true")
<td class="attachment-actions">
#set ($webInterfaceContext = $attachmentHelper.getWebInterfaceContext($action.webInterfaceContext, $attachment))
#set($webItems = $action.webInterfaceManager.getDisplayableItems("system.attachment", $webInterfaceContext))
#if ($webItems.size() > 0)
<ul>
#foreach ($item in $webItems)
#set ($isCurrent = ($context == $item.key))
<li class="#if($velocityCount == 1)first#end">#renderItemLink($item $isCurrent $webInterfaceContext)</li>
#end
</ul>
#else
#end
</td>
#end
</tr>
#if ($old == "true" && $allVersions.size() > 0)
#foreach( $attachmentVersion in $allVersions )
<tr class="history-$currentAttachmentId historicalAttachmentRow hidden" data-attachment-filename="$generalUtil.htmlEncode($attachmentVersion.fileName)" data-attachment-version="$attachmentVersion.getVersion()">
<td class="attachment-history"> </td>
<td class="filename-column">
<a class="filename" href="$generalUtil.htmlEncode("$req.contextPath$attachmentVersion.downloadPath")">#if ($velocityCount == 1)$action.getText("attach.file.version.current", $attachmentVersion.getVersion())#else$action.getText("attach.file.version.dated", $attachmentVersion.getVersion())#end</a>
</td>
<td>#if(!$attachmentHelper.attachmentsInWebDavFolder)$attachmentVersion.niceFileSize#else #end</td>
<td class="creator">
#if (!$attachmentHelper.attachmentsInWebDavFolder)
#userLink($attachmentVersion.creator)
#else
#end
</td>
<td class="created-date">#if(!$attachmentHelper.attachmentsInWebDavFolder)$action.dateFormatter.formatDateTime($attachmentVersion.creationDate)#else #end</td>
<td> </td>
<td class="comment">
#if (!$attachmentHelper.attachmentsInWebDavFolder && $attachmentVersion.comment && $attachmentVersion.comment.trim().length() > 0)
$generalUtil.htmlEncode($attachmentVersion.comment)
#else
#end
</td>
#if ($showActions == "true")
<td class="attachment-actions">
#set ($webInterfaceContext = $attachmentHelper.getWebInterfaceContext($action.webInterfaceContext, $attachmentVersion))
#set($webItems = $action.webInterfaceManager.getDisplayableItems("system.attachment.history", $webInterfaceContext))
#if ($webItems.size() > 0)
<ul>
#foreach ($item in $webItems)
#set ($isCurrent = ($context == $item.key))
<li class="#if($velocityCount == 1)first#end">#renderItemLink($item $isCurrent $webInterfaceContext)</li>
#end
</ul>
#else
#end
</td>
#end
</tr>
#end
#end
#end
</table>
Thanks!
Yes, but it is pointless, as they were attached for a good reason.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.