Table of Contents

Linking to Private Files

The Chorus America website is configured to allow files to be uploaded to a private directory. This gives some added protection to documents that aren't intended for public consumption (such as member's only or board only files) in that a "deep link" to the document will return a permission warning for users without appropriate permissions to view the file. However, many files have been uploaded to this private directory that have existing links to them in the body of publicly viewable (i.e. by anonymous users) nodes.

To work around this, some logic has been added in the cha_resource_center module to enable a file to be viewed or downloaded if the visitor is able to access the node it's linked from, regardless of whether or not the file itself is private. To take advantage of this logic, the link to the file needs to have been created by the Media manager's integration with the WYSIWYG editor, and not just linked to using the standard "Link" button i.e. it cannot be a "legacy hyperlink".

The cha_resource_center module also allows access to the file if the file's relationship to the node is managed by the File module, such as in the case of a Resource Center file that is "attached" to the node.

  1. Edit the node which contains legacy hyperlinks to private files
  2. Set the input format to "Full HTML" if it isn't already
  3. If you're updating a legacy hyperlink, select the link and use the "Unlink" button in the WYSIWYG editor (top row in between the Link and Image buttons) to unlink the text
  4. Select the text you want to link your file to
  5. Click the Media browser button, which is the furthest right button in the bottom row
  6. In the modal, click the either the Library or My Files tab
  7. Either search for your file or filter for a file type
  8. After selecting your document, click the Submit button
  9. You'll likely be given "Display as" options, the default renders a link with a small document icon before it

To make sure private files are still available to be viewed or downloaded from publicly viewable pages, you can open the page in an incognito browser window and click the new link to see if it downloads. You can double-check that the file is still private by searching for and editing the file in question at Admin > Content > Files.

The linked path to the file should automatically update in Nodes depending on whether or not the file is set to private or public. This automatic updating will only work with files that are linked using the method described here i.e. managed by the Media module. Legacy links will not update automatically.

Technical Differences

One can see the differences between a legacy link and one that has been created by the Media browser by clicking the "Disable rich-text" link below the WYSIWYG editor when editing a node. The markup that is created on the rendered page is different as well.

A legacy link will have a standard HTML link format when viewed in the WYSIWYG editor:

<a href="/system/files/resources/Board%20Self-Evaluation%20-%20Template.doc">Board Self-Evaluation</a>

And appear as an <a href> tag inside a <li> tag on the page:

    <a href="">Bylaws, U.S.</a>

Whereas a link created by the Media browser will appear more like JSON in the WYSIWYG editor (when viewing the source):

[[{"fid":"5772","view_mode":"default","fields":{"format":"default","alignment":""},"link_text":"Board End-of-Term Questions","type":"media","field_deltas":{"7":{"format":"default","alignment":""}},"attributes":{"class":"media-element file-default","data-delta":"7"}}]]

And have additional markup in the front-end:

    <div class="media media-element-container media-default">
        <div id="file-111" class="file file-document file-application-msword">
            <h2 class="element-invisible"><a href="">Bylaws Checklist, Canada</a></h2>    
            <div class="content">
                <span class="file"><img class="file-icon" alt="Microsoft Office document icon" title="application/msword" src=""> <a href="" type="application/msword; length=40448">Bylaws Checklist, Canada</a></span>

Historic Discussion

Updated: 3-21-2019