Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Exported discussion summaries builder class.

Copyright: 2019 Mihail Geshoski <mihail@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 299 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

exported_discussion_summaries:: (7 methods):
  __construct()
  build()
  get_favourites()
  get_latest_posts_authors()
  get_groups_available_in_forum()
  get_author_groups_from_posts()
  get_author_context_ids()


Class: exported_discussion_summaries  - X-Ref

Exported discussion summaries builder class.

This class is an implementation of the builder pattern (loosely). It is responsible
for taking a set of related forums, discussions, and posts and generate the exported
version of the discussion summaries.

It encapsulates the complexity involved with exporting discussions summaries. All of the relevant
additional resources will be loaded by this class in order to ensure the exporting
process can happen.

See this doc for more information on the builder pattern:
https://designpatternsphp.readthedocs.io/en/latest/Creational/Builder/README.html

__construct(renderer_base $renderer,legacy_data_mapper_factory $legacydatamapperfactory,exporter_factory $exporterfactory,vault_factory $vaultfactory,manager_factory $managerfactory)   X-Ref
Constructor.

param: renderer_base $renderer Core renderer
param: legacy_data_mapper_factory $legacydatamapperfactory Legacy data mapper factory
param: exporter_factory $exporterfactory Exporter factory
param: vault_factory $vaultfactory Vault factory
param: manager_factory $managerfactory Manager factory

build(stdClass $user,forum_entity $forum,array $discussions)   X-Ref
Build the exported discussion summaries for a given set of discussions.

This will typically be used for a list of discussions in the same forum.

return: stdClass[] List of exported posts in the same order as the $posts array.
param: stdClass $user The user to export the posts for.
param: forum_entity $forum The forum that each of the $discussions belong to
param: discussion_summary_entity[] $discussions A list of all discussion summaries to export

get_favourites(stdClass $user)   X-Ref
Get a list of all favourited discussions.

return: int[] A list of favourited itemids
param: stdClass $user The user we are getting favourites for

get_latest_posts_authors($latestposts)   X-Ref
Returns a mapped array of discussionid to the authors of the latest post

return: array Array of authors mapped to the discussion
param: array $latestposts Mapped array of discussion to latest posts.

get_groups_available_in_forum($forum)   X-Ref
Get the groups details for all groups available to the forum.

return: stdClass[]
param: forum_entity $forum The forum entity

get_author_groups_from_posts(array $posts, $forum)   X-Ref
Get the author's groups for a list of posts.

return: array Author groups indexed by author id
param: post_entity[] $posts The list of posts
param: forum_entity $forum The forum entity

get_author_context_ids(array $authorids)   X-Ref
Get the user context ids for each of the authors.

return: int[] Context ids indexed by author id
param: int[] $authorids The list of author ids to fetch context ids for.