diff --git a/htdocs/auth/lib.php b/htdocs/auth/lib.php index 10a1d14af9517bfb7a80b8ebd11fd14245cc3dd1..c3b614050b53d834026ca150090455fdd2e5edf7 100644 --- a/htdocs/auth/lib.php +++ b/htdocs/auth/lib.php @@ -750,72 +750,66 @@ function auth_get_available_auth_types($institution=null) { */ function auth_check_required_fields() { global $USER, $SESSION; - $refused = param_boolean('refuseprivacy', false); - // Privacy statement. - if (get_config('institutionstrictprivacy') && !$USER->has_latest_agreement()) { - if ($refused) { - $elements['refused'] = array( + // for the case we are mascarading as the user and we want to return to be admin user + $restoreadmin = param_integer('restore', 0); + $loginanyway = false; + if ($USER->get('parentuser') && param_exists('loginanyway')) { + $USER->loginanyway = true; + } + if ($USER->get('loginanyway')) { + $loginanyway = true; + } + // Privacy statement. + if (get_config('institutionstrictprivacy') && !$USER->has_latest_agreement() && !$restoreadmin && !$loginanyway) { + // Get all institutions of a user. + $userinstitutions = array_keys($USER->get('institutions')); + // Include the 'mahara' institution so that we may show the site privacy statement as well. + array_push($userinstitutions, 'mahara'); + + // Check if there are new privacies that need to be accepted. + $latestversions = get_latest_privacy_versions($userinstitutions, true); + + foreach ($latestversions as $privacy) { + $elements[$privacy->institution . 'text'] = array( + 'type' => 'markup', + 'value' => '
{str tag="confirmprivacyrefusal" section="admin"}
- {$form|safe} +{if $loginanyway} ++ {$loginanyway|safe} +
+{/if} +