Skip to content
Permalink
Browse files

MDL-57023 tool_usertours: Ensure that the tour key is unique

The tour key was already unique, but this change makes it unique to the
current user too.
  • Loading branch information...
andrewnicols committed Nov 22, 2016
1 parent aabebc7 commit aacdf8e2801facbe2bcb45ba6693bb6b18152ebb
Showing with 9 additions and 7 deletions.
  1. +3 −1 admin/tool/usertours/classes/tour.php
  2. +6 −6 admin/tool/usertours/tests/tour_test.php
@@ -608,6 +608,8 @@ public function should_show_for_user() {
* This is used in the session cookie to determine whether the user has seen this tour before.
*/
public function get_tour_key() {
global $USER;
$tourtime = $this->get_config('majorupdatetime', null);
if ($tourtime === null) {
@@ -622,7 +624,7 @@ public function get_tour_key() {
$tourtime = max($tourtime, $userresetdate);
}
return sprintf('tool_usertours_%d_%s', $this->get_id(), $tourtime);
return sprintf('tool_usertours_%d_%d_%s', $USER->id, $this->get_id(), $tourtime);
}
/**
@@ -729,7 +729,7 @@ public function get_tour_key_provider() {
$this->greaterThanOrEqual($time),
true,
null,
sprintf('tool_usertours_%d_%s', $id, $time),
sprintf('tool_usertours_\d_%d_%s', $id, $time),
],
'Initial tour time, no user pref' => [
@@ -738,23 +738,23 @@ public function get_tour_key_provider() {
null,
false,
null,
sprintf('tool_usertours_%d_%s', $id, $time),
sprintf('tool_usertours_\d_%d_%s', $id, $time),
],
'Initial tour time, with user reset lower' => [
$id,
[$time],
null,
false,
$time - DAYSECS,
sprintf('tool_usertours_%d_%s', $id, $time),
sprintf('tool_usertours_\d_%d_%s', $id, $time),
],
'Initial tour time, with user reset higher' => [
$id,
[$time],
null,
false,
$time + DAYSECS,
sprintf('tool_usertours_%d_%s', $id, $time + DAYSECS),
sprintf('tool_usertours_\d_%d_%s', $id, $time + DAYSECS),
],
];
}
@@ -823,8 +823,8 @@ public function test_get_tour_key($id, $getconfig, $setconfig, $willpersist, $us
set_user_preference(\tool_usertours\tour::TOUR_REQUESTED_BY_USER . $id, $userpref);
}
$this->assertEquals(
$expectation,
$this->assertRegExp(
'/' . $expectation . '/',
$tour->get_tour_key()
);
}

0 comments on commit aacdf8e

Please sign in to comment.
You can’t perform that action at this time.