mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 17:02:03 +02:00
MDL-65849 mod_forum: Add course param to the author's profile url
This commit is contained in:
parent
800563e415
commit
53b5c4f581
@ -147,6 +147,7 @@ class author extends exporter {
|
||||
$authorcontextid = $this->authorcontextid;
|
||||
$urlfactory = $this->related['urlfactory'];
|
||||
$context = $this->related['context'];
|
||||
$forum = $this->related['forum'];
|
||||
|
||||
if ($this->canview) {
|
||||
if ($author->is_deleted()) {
|
||||
@ -156,7 +157,7 @@ class author extends exporter {
|
||||
'isdeleted' => true,
|
||||
'groups' => [],
|
||||
'urls' => [
|
||||
'profile' => ($urlfactory->get_author_profile_url($author))->out(false),
|
||||
'profile' => ($urlfactory->get_author_profile_url($author, $forum->get_course_id()))->out(false),
|
||||
'profileimage' => ($urlfactory->get_author_profile_image_url($author, $authorcontextid))->out(false)
|
||||
]
|
||||
];
|
||||
@ -192,7 +193,7 @@ class author extends exporter {
|
||||
'isdeleted' => false,
|
||||
'groups' => $groups,
|
||||
'urls' => [
|
||||
'profile' => ($urlfactory->get_author_profile_url($author))->out(false),
|
||||
'profile' => ($urlfactory->get_author_profile_url($author, $forum->get_course_id()))->out(false),
|
||||
'profileimage' => ($urlfactory->get_author_profile_image_url($author, $authorcontextid))->out(false)
|
||||
]
|
||||
];
|
||||
@ -220,7 +221,8 @@ class author extends exporter {
|
||||
protected static function define_related() {
|
||||
return [
|
||||
'urlfactory' => 'mod_forum\local\factories\url',
|
||||
'context' => 'context'
|
||||
'context' => 'context',
|
||||
'forum' => 'mod_forum\local\entities\forum',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -140,6 +140,7 @@ class discussion_summary extends exporter {
|
||||
$related = [
|
||||
'urlfactory' => $this->related['urlfactory'],
|
||||
'context' => $this->related['forum']->get_context(),
|
||||
'forum' => $forum,
|
||||
];
|
||||
|
||||
$firstpostauthor = new author(
|
||||
|
@ -394,11 +394,13 @@ class url {
|
||||
* Get the url to view an author's profile.
|
||||
*
|
||||
* @param author_entity $author The author
|
||||
* @param int $courseid The course id
|
||||
* @return moodle_url
|
||||
*/
|
||||
public function get_author_profile_url(author_entity $author) : moodle_url {
|
||||
public function get_author_profile_url(author_entity $author, int $courseid) : moodle_url {
|
||||
return new moodle_url('/user/view.php', [
|
||||
'id' => $author->get_id()
|
||||
'id' => $author->get_id(),
|
||||
'course' => $courseid
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,8 @@ class mod_forum_exporters_author_testcase extends advanced_testcase {
|
||||
|
||||
$exporter = new author_exporter($author, 1, [], true, [
|
||||
'urlfactory' => \mod_forum\local\container::get_url_factory(),
|
||||
'context' => $context
|
||||
'context' => $context,
|
||||
'forum' => $forum,
|
||||
]);
|
||||
|
||||
$exportedauthor = $exporter->export($renderer);
|
||||
@ -104,7 +105,8 @@ class mod_forum_exporters_author_testcase extends advanced_testcase {
|
||||
|
||||
$exporter = new author_exporter($author, 1, [$group], true, [
|
||||
'urlfactory' => \mod_forum\local\container::get_url_factory(),
|
||||
'context' => $context
|
||||
'context' => $context,
|
||||
'forum' => $forum,
|
||||
]);
|
||||
|
||||
$exportedauthor = $exporter->export($renderer);
|
||||
@ -142,7 +144,8 @@ class mod_forum_exporters_author_testcase extends advanced_testcase {
|
||||
|
||||
$exporter = new author_exporter($author, 1, [$group], false, [
|
||||
'urlfactory' => \mod_forum\local\container::get_url_factory(),
|
||||
'context' => $context
|
||||
'context' => $context,
|
||||
'forum' => $forum,
|
||||
]);
|
||||
|
||||
$exportedauthor = $exporter->export($renderer);
|
||||
|
@ -527,7 +527,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
|
||||
* Tests is similar to the get_forum_discussion_posts only utilizing the new return structure and entities
|
||||
*/
|
||||
public function test_mod_forum_get_discussion_posts() {
|
||||
global $CFG, $PAGE;
|
||||
global $CFG;
|
||||
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
@ -538,6 +538,9 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
|
||||
$legacyfactory = mod_forum\local\container::get_legacy_data_mapper_factory();
|
||||
$entityfactory = mod_forum\local\container::get_entity_factory();
|
||||
|
||||
// Create course to add the module.
|
||||
$course1 = self::getDataGenerator()->create_course();
|
||||
|
||||
// Create a user who can track forums.
|
||||
$record = new stdClass();
|
||||
$record->trackforums = true;
|
||||
@ -551,7 +554,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
|
||||
'isdeleted' => false,
|
||||
'groups' => [],
|
||||
'urls' => [
|
||||
'profile' => $urlfactory->get_author_profile_url($user2entity),
|
||||
'profile' => $urlfactory->get_author_profile_url($user2entity, $course1->id)->out(false),
|
||||
'profileimage' => $urlfactory->get_author_profile_image_url($user2entity),
|
||||
]
|
||||
];
|
||||
@ -565,7 +568,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
|
||||
'groups' => [],
|
||||
'isdeleted' => false,
|
||||
'urls' => [
|
||||
'profile' => $urlfactory->get_author_profile_url($user3entity),
|
||||
'profile' => $urlfactory->get_author_profile_url($user3entity, $course1->id)->out(false),
|
||||
'profileimage' => $urlfactory->get_author_profile_image_url($user3entity),
|
||||
]
|
||||
];
|
||||
@ -575,9 +578,6 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
|
||||
// Set the first created user to the test user.
|
||||
self::setUser($user1);
|
||||
|
||||
// Create course to add the module.
|
||||
$course1 = self::getDataGenerator()->create_course();
|
||||
|
||||
// Forum with tracking off.
|
||||
$record = new stdClass();
|
||||
$record->course = $course1->id;
|
||||
@ -652,7 +652,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
|
||||
'groups' => [],
|
||||
'isdeleted' => true,
|
||||
'urls' => [
|
||||
'profile' => $urlfactory->get_author_profile_url($user3entity),
|
||||
'profile' => $urlfactory->get_author_profile_url($user3entity, $course1->id)->out(false),
|
||||
'profileimage' => $urlfactory->get_author_profile_image_url($user3entity),
|
||||
]
|
||||
];
|
||||
@ -2618,6 +2618,9 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
|
||||
$legacydatamapper = mod_forum\local\container::get_legacy_data_mapper_factory();
|
||||
$legacypostmapper = $legacydatamapper->get_post_data_mapper();
|
||||
|
||||
// Create course to add the module.
|
||||
$course1 = self::getDataGenerator()->create_course();
|
||||
|
||||
$user1 = self::getDataGenerator()->create_user();
|
||||
$user1entity = $entityfactory->get_author_from_stdclass($user1);
|
||||
$exporteduser1 = [
|
||||
@ -2625,7 +2628,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
|
||||
'fullname' => fullname($user1),
|
||||
'groups' => [],
|
||||
'urls' => [
|
||||
'profile' => $urlfactory->get_author_profile_url($user1entity),
|
||||
'profile' => $urlfactory->get_author_profile_url($user1entity, $course1->id)->out(false),
|
||||
'profileimage' => $urlfactory->get_author_profile_image_url($user1entity),
|
||||
],
|
||||
'isdeleted' => false,
|
||||
@ -2638,7 +2641,7 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
|
||||
'fullname' => fullname($user2),
|
||||
'groups' => [],
|
||||
'urls' => [
|
||||
'profile' => $urlfactory->get_author_profile_url($user2entity),
|
||||
'profile' => $urlfactory->get_author_profile_url($user2entity, $course1->id)->out(false),
|
||||
'profileimage' => $urlfactory->get_author_profile_image_url($user2entity),
|
||||
],
|
||||
'isdeleted' => false,
|
||||
@ -2650,9 +2653,6 @@ class mod_forum_external_testcase extends externallib_advanced_testcase {
|
||||
// Set the first created user to the test user.
|
||||
self::setUser($user1);
|
||||
|
||||
// Create course to add the module.
|
||||
$course1 = self::getDataGenerator()->create_course();
|
||||
|
||||
// Forum with tracking off.
|
||||
$record = new stdClass();
|
||||
$record->course = $course1->id;
|
||||
|
Loading…
x
Reference in New Issue
Block a user