MDL-62286 tool_policy: Add Policies link to the site footer
authorSara Arjona <sara@moodle.com>
Wed, 2 May 2018 08:47:49 +0000 (10:47 +0200)
committerSara Arjona <sara@moodle.com>
Wed, 2 May 2018 12:20:49 +0000 (14:20 +0200)
admin/tool/policy/classes/output/page_viewalldoc.php
admin/tool/policy/lib.php
admin/tool/policy/templates/page_viewalldoc.mustache

index 232547a..f8dacf4 100644 (file)
@@ -107,6 +107,10 @@ class page_viewalldoc implements renderable, templatable {
 
         $data->policies = array_values($this->policies);
 
+        array_walk($data->policies, function($item, $key) {
+            $item->policytypestr = get_string('policydoctype'.$item->type, 'tool_policy');
+        });
+
         return $data;
     }
 }
index 410e05c..6c9afa9 100644 (file)
@@ -93,6 +93,25 @@ function tool_policy_before_standard_html_head() {
     return $message;
 }
 
+/**
+ * Callback to add footer elements.
+ *
+ * @return str valid html footer content
+ */
+function tool_policy_standard_footer_html() {
+    global $CFG;
+
+    $output = '';
+    if (!empty($CFG->sitepolicyhandler)
+            && $CFG->sitepolicyhandler == 'tool_policy') {
+        $url = (new moodle_url('/admin/tool/policy/viewall.php'))->out();
+        $output .= html_writer::link($url, get_string('userpolicysettings', 'tool_policy'));
+        $output = html_writer::div($output, 'policiesfooter');
+    }
+
+    return $output;
+}
+
 /**
  * Hooks redirection to policy acceptance pages before sign up.
  */
index df70f1a..d25e40c 100644 (file)
     {
         "policies": [
             {
+                "id": "2",
                 "name": "Terms &amp; conditions",
                 "summary": "Policy <u>summary</u>",
-                "content": "Policy <em>content</em>"
+                "content": "Policy <em>content</em>",
+                "policytypestr": "Site policy"
             },
             {
+                "id": "5",
                 "name": "Privacy",
                 "summary": "We keep your information private",
-                "content": "Very private"
+                "content": "Very private",
+                "policytypestr": "Privacy policy"
             }
         ]
     }
 }}
 
+<a id="top"></a>
+<div id="policies_index" class="m-b-3">
+<ul>
+    {{#policies }}
+        <li><a href="#policy-{{id}}">{{{name}}} ({{{policytypestr}}})</a></li>
+    {{/policies }}
+</ul>
+</div>
+
 {{#policies }}
+        <hr>
     <div class="policy_version m-b-3">
         <div class="clearfix m-t-2">
-            <h1>{{{name}}}</h1>
+            <h1><a id="policy-{{id}}">{{{name}}}</a></h1>
         </div>
         <div class="policy_document_summary clearfix m-b-1">
+            <h2>{{# str }} policydocsummary, tool_policy {{/ str }}</h2>
             {{{summary}}}
         </div>
         <div class="policy_document_content m-t-2">
+            <h2>{{# str }} policydoccontent, tool_policy {{/ str }}</h2>
             {{{content}}}
         </div>
-        <hr>
+        <div class="pull-right">
+            <a href="#top">
+                {{# str }} backtotop, tool_policy {{/ str }}
+                <i class="icon text-primary fa fa-caret-up" title="{{# str }} backtotop, tool_policy {{/ str }}" ></i>
+            </a>
+        </div>
     </div>
 
 {{/policies }}