Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 39 and 402] [Versions 39 and 403]

Library of functions for forum outside of the core api

Copyright: 1999 onwards Martin Dougiamas {@link http://moodle.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 756 lines (30 kb)
Included or required:0 times
Referenced: 9 times
Includes or requires: 0 files

Defines 2 classes

forum_portfolio_caller:: (14 methods):
  expected_callbackargs()
  __construct()
  load_data()
  get_return_url()
  get_navigation()
  prepare_package()
  prepare_post_leap2a()
  copy_files()
  prepare_post()
  get_sha1()
  expected_time()
  check_permissions()
  display_name()
  base_supported_formats()

forum_file_info_container:: (12 methods):
  __construct()
  get_params()
  is_writable()
  is_directory()
  get_visible_name()
  get_children()
  get_filtered_children()
  get_non_empty_children()
  count_non_empty_children()
  get_parent()
  mod_forum_get_tagged_posts()
  forum_update_calendar()


Class: forum_portfolio_caller  - X-Ref


expected_callbackargs()   X-Ref

return: array

__construct($callbackargs)   X-Ref

param: array $callbackargs

load_data()   X-Ref


get_return_url()   X-Ref

return: string

get_navigation()   X-Ref

return: array

prepare_package()   X-Ref
either a whole discussion
a single post, with or without attachment
or just an attachment with no post

return: mixed

prepare_post_leap2a(portfolio_format_leap2a_writer $leapwriter, $post, $posthtml)   X-Ref
helper function to add a leap2a entry element
that corresponds to a single forum post,
including any attachments

the entry/ies are added directly to the leapwriter, which is passed by ref

param: portfolio_format_leap2a_writer $leapwriter writer object to add entries to
param: object $post                               the stdclass object representing the database record
param: string $posthtml                           the content of the post (prepared by {@link prepare_post}
return: int id of new entry

copy_files($files, $justone=false)   X-Ref

param: array $files
param: mixed $justone false of id of single file to copy
return: bool|void

prepare_post($post, $fileoutputextras=null)   X-Ref
this is a very cut down version of what is in forum_make_mail_post

param: int $post
return: string

get_sha1()   X-Ref

return: string

expected_time()   X-Ref
No description

check_permissions()   X-Ref

return: bool

display_name()   X-Ref

return: string

base_supported_formats()   X-Ref
No description

Class: forum_file_info_container  - X-Ref

Class representing the virtual node with all itemids in the file browser

__construct($browser, $course, $cm, $context, $areas, $filearea)   X-Ref
Constructor (in case you did not realize it ;-)

param: file_browser $browser
param: stdClass $course
param: stdClass $cm
param: stdClass $context
param: array $areas
param: string $filearea

get_params()   X-Ref

return: array with keys contextid, filearea, itemid, filepath and filename

is_writable()   X-Ref
Can new files or directories be added via the file browser

return: bool

is_directory()   X-Ref
Should this node be considered as a folder in the file browser

return: bool

get_visible_name()   X-Ref
Returns localised visible name of this node

return: string

get_children()   X-Ref
Returns list of children nodes

return: array of file_info instances

get_filtered_children($extensions = '*', $countonly = false, $returnemptyfolders = false)   X-Ref
Help function to return files matching extensions or their count

param: string|array $extensions, either '*' or array of lowercase extensions, i.e. array('.gif','.jpg')
param: bool|int $countonly if false returns the children, if an int returns just the
param: bool $returnemptyfolders if true returns items that don't have matching files inside
return: array|int array of file_info instances or the count

get_non_empty_children($extensions = '*')   X-Ref
Returns list of children which are either files matching the specified extensions
or folders that contain at least one such file.

param: string|array $extensions, either '*' or array of lowercase extensions, i.e. array('.gif','.jpg')
return: array of file_info instances

count_non_empty_children($extensions = '*', $limit = 1)   X-Ref
Returns the number of children which are either files matching the specified extensions
or folders containing at least one such file.

param: string|array $extensions, for example '*' or array('.gif','.jpg')
param: int $limit stop counting after at least $limit non-empty children are found
return: int

get_parent()   X-Ref
Returns parent file_info instance

return: file_info or null for root

mod_forum_get_tagged_posts($tag, $exclusivemode = false, $fromctx = 0, $ctx = 0, $rec = 1, $page = 0)   X-Ref
Returns forum posts tagged with a specified tag.

This is a callback used by the tag area mod_forum/forum_posts to search for forum posts
tagged with a specific tag.

param: core_tag_tag $tag
param: bool $exclusivemode if set to true it means that no other entities tagged with this tag
param: int $fromctx context id where the link was displayed, may be used by callbacks
param: int $ctx context id where to search for records
param: bool $rec search in subcontexts as well
param: int $page 0-based number of page being displayed
return: \core_tag\output\tagindex

forum_update_calendar($forum, $cmid)   X-Ref
Update the calendar entries for this forum activity.

param: stdClass $forum the row from the database table forum.
param: int $cmid The coursemodule id
return: bool