Commit c9209bcf authored by Robert Lyon's avatar Robert Lyon
Browse files

Bug 1758733: Allow non-admin to see correct legal page when logged in



behatnotneeded

Change-Id: I0da3f8a12d62ff5142974e0f068ddf591c75979d
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 929c65cb
...@@ -22,7 +22,7 @@ if (!is_logged_in()) { ...@@ -22,7 +22,7 @@ if (!is_logged_in()) {
throw new AccessDeniedException(); throw new AccessDeniedException();
} }
$form = privacy_form(); $form = privacy_form(!get_config('institutionstrictprivacy'), !get_config('institutionstrictprivacy'));
// JQuery logic for panel hide/show submit button. // JQuery logic for panel hide/show submit button.
$js = <<< EOF $js = <<< EOF
...@@ -39,5 +39,5 @@ setpageicon($smarty, 'icon-umbrella'); ...@@ -39,5 +39,5 @@ setpageicon($smarty, 'icon-umbrella');
$smarty->assign('form', $form); $smarty->assign('form', $form);
$smarty->assign('INLINEJAVASCRIPT', $js); $smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('description', get_string('userprivacypagedescription', 'admin')); $smarty->assign('description', get_string('userprivacypagedescription1', 'admin'));
$smarty->display('account/userprivacy.tpl'); $smarty->display('account/userprivacy.tpl');
...@@ -146,6 +146,7 @@ else { ...@@ -146,6 +146,7 @@ else {
setpageicon($smarty, 'icon-umbrella'); setpageicon($smarty, 'icon-umbrella');
$smarty->assign('INLINEJAVASCRIPT', $js); $smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('results', $data); $smarty->assign('results', $data);
$smarty->assign('selectedtab', $selectedtab);
$smarty->assign('latestVersions', $latestVersions); $smarty->assign('latestVersions', $latestVersions);
$smarty->assign('versionid', $versionid); $smarty->assign('versionid', $versionid);
$smarty->assign('link', "admin/site/privacy.php?id="); $smarty->assign('link', "admin/site/privacy.php?id=");
......
...@@ -745,11 +745,13 @@ function auth_get_available_auth_types($institution=null) { ...@@ -745,11 +745,13 @@ function auth_get_available_auth_types($institution=null) {
/** /**
* Build the agree with or withdraw consent to privacy statement * Build the agree with or withdraw consent to privacy statement
* *
* @param ignoreagreevalue true when a new privacy statement needs to be accepted, * @param ignoreagreevalue true - when a new privacy statement needs to be accepted,
* false when the form will be displayed to allow the consent withdraw. * false - when the form will be displayed to allow the consent withdraw.
* @return form * @param ignoreformswitch If true we do not show the form's switch fields. Useful if strict privacy is off.
*
* @return pieform form
*/ */
function privacy_form($ignoreagreevalue = false) { function privacy_form($ignoreagreevalue = false, $ignoreformswitch = false) {
global $USER; global $USER;
// Get all institutions of a user. // Get all institutions of a user.
...@@ -782,6 +784,7 @@ function privacy_form($ignoreagreevalue = false) { ...@@ -782,6 +784,7 @@ function privacy_form($ignoreagreevalue = false) {
$smarty->assign('privacytitle', $title); $smarty->assign('privacytitle', $title);
$smarty->assign('privacytime', format_date(strtotime($privacy->ctime))); $smarty->assign('privacytime', format_date(strtotime($privacy->ctime)));
$smarty->assign('ignoreagreevalue', $ignoreagreevalue); $smarty->assign('ignoreagreevalue', $ignoreagreevalue);
$smarty->assign('ignoreformswitch', $ignoreformswitch);
$htmlbegin = $smarty->fetch('privacy_panel_begin.tpl'); $htmlbegin = $smarty->fetch('privacy_panel_begin.tpl');
//Build form elements. //Build form elements.
...@@ -793,21 +796,21 @@ function privacy_form($ignoreagreevalue = false) { ...@@ -793,21 +796,21 @@ function privacy_form($ignoreagreevalue = false) {
'type' => 'hidden', 'type' => 'hidden',
'value' => $privacy->id, 'value' => $privacy->id,
); );
if (!$ignoreformswitch) {
$elements[$privacy->institution . $privacy->type] = array( $elements[$privacy->institution . $privacy->type] = array(
'type' => 'switchbox', 'type' => 'switchbox',
'title' => get_string('privacyagreement', 'admin', get_string($privacy->type . 'lowcase', 'admin')), 'title' => get_string('privacyagreement', 'admin', get_string($privacy->type . 'lowcase', 'admin')),
'description' => $privacy->agreed ? get_string('privacyagreedto', 'admin', 'description' => $privacy->agreed ? get_string('privacyagreedto', 'admin',
get_string($privacy->type . 'lowcase', 'admin'), format_date(strtotime($privacy->agreedtime))) : '', get_string($privacy->type . 'lowcase', 'admin'), format_date(strtotime($privacy->agreedtime))) : '',
'defaultvalue' => $privacy->agreed ? true : false, 'defaultvalue' => $privacy->agreed ? true : false,
'disabled' => ($privacy->agreed && $ignoreagreevalue) ? true : false, 'disabled' => ($privacy->agreed && $ignoreagreevalue) ? true : false,
'required' => true, 'required' => true,
); );
$elements[$privacy->institution . $privacy->type . 'switch'] = array( $elements[$privacy->institution . $privacy->type . 'switch'] = array(
'type' => 'hidden', 'type' => 'hidden',
'value' => ($privacy->agreed && $ignoreagreevalue) ? 'disabled' : 'enabled', 'value' => ($privacy->agreed && $ignoreagreevalue) ? 'disabled' : 'enabled',
); );
}
$smarty = smarty_core(); $smarty = smarty_core();
$smarty->assign('ignoreagreevalue', $ignoreagreevalue); $smarty->assign('ignoreagreevalue', $ignoreagreevalue);
$htmlend = $smarty->fetch('privacy_panel_end.tpl'); $htmlend = $smarty->fetch('privacy_panel_end.tpl');
...@@ -818,15 +821,19 @@ function privacy_form($ignoreagreevalue = false) { ...@@ -818,15 +821,19 @@ function privacy_form($ignoreagreevalue = false) {
} }
$classhidden = $ignoreagreevalue ? '' : 'js-hidden'; $classhidden = $ignoreagreevalue ? '' : 'js-hidden';
$elements['submit'] = array( if (!$ignoreformswitch) {
'class' => 'btn-primary ' . $classhidden, $elements['submit'] = array(
'type' => 'submit', 'class' => 'btn-primary ' . $classhidden,
'value' => get_string('savechanges', 'admin') 'type' => 'submit',
); 'value' => get_string('savechanges', 'admin')
);
}
$form = pieform(array( $form = pieform(array(
'name' => 'agreetoprivacy', 'name' => 'agreetoprivacy',
'elements' => $elements, 'elements' => $elements,
)); ));
return $form; return $form;
} }
/** /**
......
...@@ -1366,7 +1366,7 @@ $string['institutionprivacystatement'] = 'Institution privacy statement'; ...@@ -1366,7 +1366,7 @@ $string['institutionprivacystatement'] = 'Institution privacy statement';
$string['institutiontermsandconditions'] = 'Institution terms and conditions'; $string['institutiontermsandconditions'] = 'Institution terms and conditions';
$string['institutionprivacyconsentdate'] = 'Institution privacy consent reviewed'; $string['institutionprivacyconsentdate'] = 'Institution privacy consent reviewed';
$string['institutiontermsconsentdate'] = 'Institution terms and conditions consent reviewed'; $string['institutiontermsconsentdate'] = 'Institution terms and conditions consent reviewed';
$string['userprivacypagedescription'] = 'Displayed are the current privacy statements and terms and conditions to which you consented.'; $string['userprivacypagedescription1'] = 'Displayed are the current privacy statements and terms and conditions.';
$string['lastupdated'] = 'Last updated on'; $string['lastupdated'] = 'Last updated on';
$string['newprivacy'] = 'Before entering your account, please read the information displayed below.'; $string['newprivacy'] = 'Before entering your account, please read the information displayed below.';
$string['privacyagreement'] = 'I consent to the %s'; $string['privacyagreement'] = 'I consent to the %s';
......
{include file="header.tpl"} {include file="header.tpl"}
{if $versionid && in_array($versionid, $latestVersions)} {if $versionid && in_array($versionid, $latestVersions)}
<div class="lead">{str tag="privacypagedescription" section="admin"}</div> <div class="lead">
{if $selectedtab == 'termsandconditions'}
{str tag="termspagedescription" section="admin"}
{else}
{str tag="privacypagedescription" section="admin"}
{/if}
</div>
{if $pageeditform} {if $pageeditform}
<div class="col-md-9"> <div class="col-md-9">
<div class="panel panel-default"> <div class="panel panel-default">
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
</a> </a>
</h4> </h4>
</legend> </legend>
<div class="fieldset-body collapse {if !($privacy->agreed && $ignoreagreevalue)}in{/if}" id="dropdown{$privacy->id}"> <div class="fieldset-body collapse {if (!($privacy->agreed && $ignoreagreevalue) || $ignoreformswitch)}in{/if}" id="dropdown{$privacy->id}">
<span class="text-midtone pull-right">{str tag='lastupdated' section='admin'} {$privacytime} </span> <span class="text-midtone pull-right">{str tag='lastupdated' section='admin'} {$privacytime} </span>
<div class="last-updated-offset"> <div class="last-updated-offset">
{$privacy->content|safe} {$privacy->content|safe}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment