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.
/mod/book/ -> lib.php (source)

Functions that are not part of a class:

book_get_numbering_types()   X-Ref
Returns list of available numbering types

return: array

book_get_nav_types()   X-Ref
Returns list of available navigation link types.

return: array

book_get_nav_classes()   X-Ref
Returns list of available navigation link CSS classes.

return: array

book_add_instance($data, $mform)   X-Ref
Add book instance.

return: int new book instance id
param: stdClass $data
param: stdClass $mform

book_update_instance($data, $mform)   X-Ref
Update book instance.

return: bool true
param: stdClass $data
param: stdClass $mform

book_delete_instance($id)   X-Ref
Delete book instance by activity id

return: bool success
param: int $id

book_print_recent_activity($course, $viewfullnames, $timestart)   X-Ref
Given a course and a time, this module should find recent activity
that has occurred in book activities and print it out.

return: bool true if there was output, or false is there was none
param: stdClass $course
param: bool $viewfullnames
param: int $timestart

book_reset_userdata($data)   X-Ref
This function is used by the reset_course_userdata function in moodlelib.

return: array status array
param: $data the data submitted from the reset course.

book_reset_course_form_definition(&$mform)   X-Ref
The elements to add the course reset form.

param: moodleform $mform

book_cron()   X-Ref
No cron in book.

return: bool

book_grades($bookid)   X-Ref
No grading in book.

return: null
param: int $bookid

book_scale_used()   X-Ref


book_scale_used_anywhere($scaleid)   X-Ref
Checks if scale is being used by any instance of book

This is used to find out if scale used anywhere

return: bool true if the scale is used by any book
param: int $scaleid

book_get_view_actions()   X-Ref
Return read actions.

Note: This is not used by new logging system. Event with
crud = 'r' and edulevel = LEVEL_PARTICIPATING will
be considered as view action.

return: array

book_get_post_actions()   X-Ref
Return write actions.

Note: This is not used by new logging system. Event with
crud = ('c' || 'u' || 'd') and edulevel = LEVEL_PARTICIPATING
will be considered as post action.

return: array

book_supports($feature)   X-Ref
Supported features

return: mixed True if module supports feature, false if not, null if doesn't know or string for the module purpose.
param: string $feature FEATURE_xx constant for requested feature

book_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $booknode)   X-Ref
Adds module specific settings to the settings block

return: void
param: settings_navigation $settingsnav The settings navigation object
param: navigation_node $booknode The node to add module settings to

book_get_file_areas($course, $cm, $context)   X-Ref
Lists all browsable file areas

return: array
param: object $course
param: object $cm
param: object $context

book_get_file_info($browser, $areas, $course, $cm, $context, $filearea, $itemid, $filepath, $filename)   X-Ref
File browsing support for book module chapter area.

return: object file_info instance or null if not found
param: object $browser
param: object $areas
param: object $course
param: object $cm
param: object $context
param: string $filearea
param: int $itemid
param: string $filepath
param: string $filename

book_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()   X-Ref
Serves the book attachments. Implements needed access control ;-)

return: bool false if file not found, does not return if found - just send the file
param: stdClass $course course object
param: cm_info $cm course module object
param: context $context context object
param: string $filearea file area
param: array $args extra arguments
param: bool $forcedownload whether or not force download
param: array $options additional options affecting the file serving

book_page_type_list($pagetype, $parentcontext, $currentcontext)   X-Ref
Return a list of page types

return: array
param: string $pagetype current page type
param: stdClass $parentcontext Block's parent context
param: stdClass $currentcontext Current context of block

book_export_contents($cm, $baseurl)   X-Ref
Export book resource contents

return: array of file content
param: stdClass $cm     Course module object
param: string $baseurl  Base URL for file downloads

book_view($book, $chapter, $islastchapter, $course, $cm, $context)   X-Ref
Mark the activity completed (if required) and trigger the course_module_viewed event.

param: stdClass $book       book object
param: stdClass $chapter    chapter object
param: bool $islaschapter   is the las chapter of the book?
param: stdClass $course     course object
param: stdClass $cm         course module object
param: stdClass $context    context object

book_check_updates_since(cm_info $cm, $from, $filter = array()   X-Ref
Check if the module has any update that affects the current user since a given time.

return: stdClass an object with the different type of areas indicating if they were updated or not
param: cm_info $cm course module data
param: int $from the time to check updates from
param: array $filter  if we need to check only specific updates

mod_book_get_fontawesome_icon_map()   X-Ref
Get icon mapping for font-awesome.


mod_book_core_calendar_provide_event_action(calendar_event $event,\core_calendar\action_factory $factory,int $userid = 0)   X-Ref
This function receives a calendar event and returns the action associated with it, or null if there is none.

This is used by block_myoverview in order to display the event appropriately. If null is returned then the event
is not displayed on the block.

return: \core_calendar\local\event\entities\action_interface|null
param: calendar_event $event
param: \core_calendar\action_factory $factory
param: int $userid User id to use for all capability checks, etc. Set to 0 for current user (default).