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()) {
throw new AccessDeniedException();
}
$form = privacy_form();
$form = privacy_form(!get_config('institutionstrictprivacy'), !get_config('institutionstrictprivacy'));
// JQuery logic for panel hide/show submit button.
$js = <<< EOF
......@@ -39,5 +39,5 @@ setpageicon($smarty, 'icon-umbrella');
$smarty->assign('form', $form);
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('description', get_string('userprivacypagedescription', 'admin'));
$smarty->assign('description', get_string('userprivacypagedescription1', 'admin'));
$smarty->display('account/userprivacy.tpl');
......@@ -146,6 +146,7 @@ else {
setpageicon($smarty, 'icon-umbrella');
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('results', $data);
$smarty->assign('selectedtab', $selectedtab);
$smarty->assign('latestVersions', $latestVersions);
$smarty->assign('versionid', $versionid);
$smarty->assign('link', "admin/site/privacy.php?id=");
......
......@@ -745,11 +745,13 @@ function auth_get_available_auth_types($institution=null) {
/**
* Build the agree with or withdraw consent to privacy statement
*
* @param ignoreagreevalue true when a new privacy statement needs to be accepted,
* false when the form will be displayed to allow the consent withdraw.
* @return form
* @param ignoreagreevalue true - when a new privacy statement needs to be accepted,
* false - when the form will be displayed to allow the consent withdraw.
* @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;
// Get all institutions of a user.
......@@ -782,6 +784,7 @@ function privacy_form($ignoreagreevalue = false) {
$smarty->assign('privacytitle', $title);
$smarty->assign('privacytime', format_date(strtotime($privacy->ctime)));
$smarty->assign('ignoreagreevalue', $ignoreagreevalue);
$smarty->assign('ignoreformswitch', $ignoreformswitch);
$htmlbegin = $smarty->fetch('privacy_panel_begin.tpl');
//Build form elements.
......@@ -793,21 +796,21 @@ function privacy_form($ignoreagreevalue = false) {
'type' => 'hidden',
'value' => $privacy->id,
);
$elements[$privacy->institution . $privacy->type] = array(
'type' => 'switchbox',
'title' => get_string('privacyagreement', 'admin', get_string($privacy->type . 'lowcase', 'admin')),
'description' => $privacy->agreed ? get_string('privacyagreedto', 'admin',
get_string($privacy->type . 'lowcase', 'admin'), format_date(strtotime($privacy->agreedtime))) : '',
'defaultvalue' => $privacy->agreed ? true : false,
'disabled' => ($privacy->agreed && $ignoreagreevalue) ? true : false,
'required' => true,
);
$elements[$privacy->institution . $privacy->type . 'switch'] = array(
'type' => 'hidden',
'value' => ($privacy->agreed && $ignoreagreevalue) ? 'disabled' : 'enabled',
);
if (!$ignoreformswitch) {
$elements[$privacy->institution . $privacy->type] = array(
'type' => 'switchbox',
'title' => get_string('privacyagreement', 'admin', get_string($privacy->type . 'lowcase', 'admin')),
'description' => $privacy->agreed ? get_string('privacyagreedto', 'admin',
get_string($privacy->type . 'lowcase', 'admin'), format_date(strtotime($privacy->agreedtime))) : '',
'defaultvalue' => $privacy->agreed ? true : false,
'disabled' => ($privacy->agreed && $ignoreagreevalue) ? true : false,
'required' => true,
);
$elements[$privacy->institution . $privacy->type . 'switch'] = array(
'type' => 'hidden',
'value' => ($privacy->agreed && $ignoreagreevalue) ? 'disabled' : 'enabled',
);
}
$smarty = smarty_core();
$smarty->assign('ignoreagreevalue', $ignoreagreevalue);
$htmlend = $smarty->fetch('privacy_panel_end.tpl');
......@@ -818,15 +821,19 @@ function privacy_form($ignoreagreevalue = false) {
}
$classhidden = $ignoreagreevalue ? '' : 'js-hidden';
$elements['submit'] = array(
'class' => 'btn-primary ' . $classhidden,
'type' => 'submit',
'value' => get_string('savechanges', 'admin')
);
if (!$ignoreformswitch) {
$elements['submit'] = array(
'class' => 'btn-primary ' . $classhidden,
'type' => 'submit',
'value' => get_string('savechanges', 'admin')
);
}
$form = pieform(array(
'name' => 'agreetoprivacy',
'elements' => $elements,
));
return $form;
}
/**
......
......@@ -1366,7 +1366,7 @@ $string['institutionprivacystatement'] = 'Institution privacy statement';
$string['institutiontermsandconditions'] = 'Institution terms and conditions';
$string['institutionprivacyconsentdate'] = 'Institution privacy 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['newprivacy'] = 'Before entering your account, please read the information displayed below.';
$string['privacyagreement'] = 'I consent to the %s';
......
{include file="header.tpl"}
{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}
<div class="col-md-9">
<div class="panel panel-default">
......
......@@ -9,7 +9,7 @@
</a>
</h4>
</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>
<div class="last-updated-offset">
{$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