Search moodle.org's
Developer Documentation

See Release Notes

  • 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.
/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.

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

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

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

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

param: int $id
return: bool success

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.

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

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

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

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.

param: int $bookid
return: null

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

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

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

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

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

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

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

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

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

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
return: object file_info instance or null if not found

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

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
return: bool false if file not found, does not return if found - just send the file

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

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

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

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

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.

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
return: stdClass an object with the different type of areas indicating if they were updated or not

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.

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).
return: \core_calendar\local\event\entities\action_interface|null