Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 401 and 402] [Versions 401 and 403]

This file defines an adhoc task to send notifications.

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

Defines 1 class

send_user_notifications:: (10 methods):
  execute()
  prepare_data()
  send_post()
  get_post_author()
  get_renderer()
  get_message_headers()
  get_reply_address()
  can_post()
  can_view_fullnames()
  minimise_user_record()


Class: send_user_notifications  - X-Ref

Adhoc task to send user forum notifications.

execute()   X-Ref
Send out messages.


prepare_data(array $postids)   X-Ref
Prepare all data for this run.

Take all post ids, and fetch the relevant authors, discussions, forums, and courses for them.

param: int[]   $postids The list of post IDs

send_post($course, $forum, $discussion, $post, $cm, $context)   X-Ref
Send the specified post for the current user.

param: \stdClass   $course
param: \stdClass   $forum
param: \stdClass   $discussion
param: \stdClass   $post
param: \stdClass   $cm
param: \context    $context

get_post_author($userid, $course, $forum, $cm, $context)   X-Ref
Fetch and initialise the post author.

param: int         $userid The id of the user to fetch
param: \stdClass   $course
param: \stdClass   $forum
param: \stdClass   $cm
param: \context    $context
return: \stdClass

get_renderer($html = false)   X-Ref
Helper to fetch the required renderer, instantiating as required.

param: bool    $html Whether to fetch the HTML renderer
return: \core_renderer

get_message_headers($course, $forum, $discussion, $post, $a, $message)   X-Ref
Get the list of message headers.

param: \stdClass   $course
param: \stdClass   $forum
param: \stdClass   $discussion
param: \stdClass   $post
param: \stdClass   $a The list of strings for this  post
param: \core\message\message $message The message to be sent
return: \stdClass

get_reply_address($course, $forum, $discussion, $post, $cm, $context)   X-Ref
Get a no-reply address for this user to reply to the current post.

param: \stdClass   $course
param: \stdClass   $forum
param: \stdClass   $discussion
param: \stdClass   $post
param: \stdClass   $cm
param: \context    $context
return: string

can_post($course, $forum, $discussion, $post, $cm, $context)   X-Ref
Check whether the user can post.

param: \stdClass   $course
param: \stdClass   $forum
param: \stdClass   $discussion
param: \stdClass   $post
param: \stdClass   $cm
param: \context    $context
return: bool

can_view_fullnames($course, $forum, $discussion, $post, $cm, $context)   X-Ref
Check whether the user can view full names of other users.

param: \stdClass   $course
param: \stdClass   $forum
param: \stdClass   $discussion
param: \stdClass   $post
param: \stdClass   $cm
param: \context    $context
return: bool

minimise_user_record(\stdClass $user)   X-Ref
Removes properties from user record that are not necessary for sending post notifications.

param: \stdClass   $user