From aaedf52f7af8ed1e7f4e354ec9405d89613d6643 Mon Sep 17 00:00:00 2001
From: Sam White <webmaster@ycra.org.uk>
Date: Wed, 8 Dec 2021 11:49:05 +0000
Subject: [PATCH] Add document link helper functions.

---
 public_html/includes/html-templating.php | 4 ++++
 public_html/includes/utils.php           | 6 ++++++
 public_html/join.php                     | 2 +-
 public_html/winter-event.php             | 2 +-
 4 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/public_html/includes/html-templating.php b/public_html/includes/html-templating.php
index ac29f2e..0ec4808 100644
--- a/public_html/includes/html-templating.php
+++ b/public_html/includes/html-templating.php
@@ -26,6 +26,10 @@ function javascript($name) {
           src($rel_path . $suffix);?>"></script><?php
 }
 
+function document_href($filename) {
+  return href(document_link($filename));
+}
+
 // Link output helper functions.
 function href($path) {
   echo 'href="';
diff --git a/public_html/includes/utils.php b/public_html/includes/utils.php
index bb62dc0..0ab5ab8 100644
--- a/public_html/includes/utils.php
+++ b/public_html/includes/utils.php
@@ -35,6 +35,12 @@ function cache_control_suffix($path) {
   return "?v=$modified";
 }
 
+function document_link($filename) {
+  $rel_path = "docs/$filename";
+  $suffix = cache_control_suffix($rel_path);
+  return $rel_path . $suffix;
+}
+
 function show_error_list($errors) {
   if (empty($errors)) return;?>
   <div class="error"><?php
diff --git a/public_html/join.php b/public_html/join.php
index 5ece72e..1e8aae3 100644
--- a/public_html/join.php
+++ b/public_html/join.php
@@ -120,7 +120,7 @@ function content() {?>
   then subsequently pay for membership. The membership fee is currently
   <b>£15.00</b> for one year.</p>
 
-  <p>Please view our <a <?php href('docs/privacy-policy-v2.pdf');?>>privacy policy</a>
+  <p>Please view our <a <?php document_href('privacy-policy-v2.pdf');?>>privacy policy</a>
   for information on how we will process your data.</p>
 
   <?php show_error_list($errors);?>
diff --git a/public_html/winter-event.php b/public_html/winter-event.php
index 04f3d09..c1c654d 100644
--- a/public_html/winter-event.php
+++ b/public_html/winter-event.php
@@ -89,7 +89,7 @@ function content() {?>
       <label for="consent">
         I agree for the data I submit with this form to be processed in
         accordance with the
-        <a <?php href('docs/privacy-policy-v2.pdf');?>>YCRA privacy policy</a>.
+        <a <?php document_href('privacy-policy-v2.pdf');?>>YCRA privacy policy</a>.
       </label>
     </div>
 
-- 
2.25.1