Search moodle.org's
Developer Documentation

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
  • Differences Between: [Versions 311 and 400] [Versions 37 and 311]

    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: 617 lines (22 kb)
    Included or required:0 times
    Referenced: 0 times
    Includes or requires: 0 files

    Defines 1 class

    send_user_digests:: (12 methods):
      execute()
      prepare_data()
      empty_queue()
      fill_digest_cache()
      get_post_author()
      add_message_header()
      add_discussion_header()
      add_post_body()
      add_discussion_footer()
      get_maildigest()
      send_mail()
      get_renderer()


    Class: send_user_digests  - X-Ref

    Adhoc task to send moodle forum digests for the specified user.

    execute()   X-Ref
    Send out messages.


    prepare_data(int $timenow)   X-Ref
    Prepare the data for this run.

    Note: This will also remove posts from the queue.

    param: int     $timenow

    empty_queue(int $userid, int $timemodified)   X-Ref
    Empty the queue of posts for this user.

    param: int $userid user id which queue elements are going to be removed.
    param: int $timemodified up time limit of the queue elements to be removed.

    fill_digest_cache()   X-Ref
    Fill the cron digest cache.


    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

    add_message_header()   X-Ref
    Add the header to this message.


    add_discussion_header($discussion, $forum, $course)   X-Ref
    Add the header for this discussion.

    param: \stdClass   $discussion The discussion to add the footer for
    param: \stdClass   $forum The forum that the discussion belongs to
    param: \stdClass   $course The course that the forum belongs to

    add_post_body($author, $post, $discussion, $forum, $cm, $course)   X-Ref
    Add the body of this post.

    param: \stdClass   $author The author of the post
    param: \stdClass   $post The post being sent
    param: \stdClass   $discussion The discussion that the post is in
    param: \stdClass   $forum The forum that the discussion belongs to
    param: \cminfo     $cm The cminfo object for the forum
    param: \stdClass   $course The course that the forum belongs to

    add_discussion_footer($discussion)   X-Ref
    Add the footer for this discussion.

    param: \stdClass   $discussion The discussion to add the footer for

    get_maildigest($forumid)   X-Ref
    Get the forum digest type for the specified forum, failing back to
    the default setting for the current user if not specified.

    param: int     $forumid
    return: int

    send_mail()   X-Ref
    Send the composed message to the user.


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

    param: int     $maildigest The type of mail digest being sent
    param: bool    $html Whether to fetch the HTML renderer
    return: \core_renderer