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.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400]

Discussion list renderer.

Copyright: 2019 Andrew Nicols <andrew@nicols.co.uk>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 425 lines (17 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

discussion_list:: (7 methods):
  __construct()
  render()
  render_new_discussion()
  get_discussion_form()
  get_page_size()
  get_page_number()
  get_notifications()


Class: discussion_list  - X-Ref

The discussion list renderer.

__construct(forum_entity $forum,renderer_base $renderer,legacy_data_mapper_factory $legacydatamapperfactory,exporter_factory $exporterfactory,vault_factory $vaultfactory,builder_factory $builderfactory,capability_manager $capabilitymanager,url_factory $urlfactory,forum_gradeitem $forumgradeitem,string $template,array $notifications = [],callable $postprocessfortemplate = null)   X-Ref
Constructor for a new discussion list renderer.

param: forum_entity        $forum The forum entity to be rendered
param: renderer_base       $renderer The renderer used to render the view
param: legacy_data_mapper_factory $legacydatamapperfactory The factory used to fetch a legacy record
param: exporter_factory    $exporterfactory The factory used to fetch exporter instances
param: vault_factory       $vaultfactory The factory used to fetch the vault instances
param: builder_factory     $builderfactory The factory used to fetch the builder instances
param: capability_manager  $capabilitymanager The managed used to check capabilities on the forum
param: url_factory         $urlfactory The factory used to create URLs in the forum
param: string              $template
param: notification[]      $notifications A list of any notifications to be displayed within the page
param: callable|null       $postprocessfortemplate Callback function to process discussion lists for templates

render(stdClass $user,\cm_info $cm,?int $groupid,?int $sortorder,?int $pageno,?int $pagesize,int $displaymode = null,bool $enablediscussioncreation = true)   X-Ref
Render for the specified user.

return: string      The rendered content for display
param: stdClass    $user The user to render for
param: cm_info     $cm The course module info for this discussion list
param: int         $groupid The group to render
param: int         $sortorder The sort order to use when selecting the discussions in the list
param: int         $pageno The zero-indexed page number to use
param: int         $pagesize The number of discussions to show on the page
param: int         $displaymode The discussion display mode
param: bool        $enablediscussioncreation To show the discussion button.

render_new_discussion(stdClass $user, ?int $groupid)   X-Ref
Add new discussion button to the action bar for tertiary nav.

return: string rendered HTML string
param: stdClass $user The user object.
param: int|null $groupid The group id.

get_discussion_form(stdClass $user, \cm_info $cm, ?int $groupid)   X-Ref
Get the mod_forum_post_form. This is the default boiler plate from mod_forum/post_form.php with the inpage flag caveat

return: string The rendered html
param: stdClass $user The user the form is being generated for
param: \cm_info $cm
param: int $groupid The groupid if any

get_page_size(?int $pagesize)   X-Ref
Fetch the page size to use when displaying the page.

return: int         The normalised page size
param: int         $pagesize The number of discussions to show on the page

get_page_number(?int $pageno)   X-Ref
Fetch the current page number (zero-indexed).

return: int         The normalised page number
param: int         $pageno The zero-indexed page number to use

get_notifications(stdClass $user, ?int $groupid)   X-Ref
Get the list of notification for display.

return: array
param: stdClass $user The viewing user
param: int|null $groupid The forum's group id