MDL-61844 policy: Avoid to accept new policies during current session

Avoid redirection for accepting new policies during the manager user session
when $user->policyagreed=0 and he/she activates the first policy for logged in users.

Part of MDL-61864
This commit is contained in:
Sara Arjona
2018-04-16 11:30:14 +08:00
committed by Marina Glancy
parent 3f9b276b97
commit 4e9e2b0a0a
4 changed files with 25 additions and 15 deletions
+6 -1
View File
@@ -477,7 +477,7 @@ class api {
* @param int $versionid
*/
public static function make_current($versionid) {
global $DB;
global $DB, $USER;
$policyversion = new policy_version($versionid);
if (! $policyversion->get('id') || $policyversion->get('archived')) {
@@ -498,6 +498,11 @@ class api {
// Reset the policyagreed flag to force everybody re-accept the policies.
$DB->set_field('user', 'policyagreed', 0);
// Make sure that the current user is not immediately redirected to the policy acceptance page.
if (isloggedin() && !isguestuser()) {
$USER->policyagreed = 1;
}
}
/**