Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
mod_book

Namespaces

namespace  mod_book
  
 
namespace  mod_book\analytics\indicator
  
 
namespace  mod_book\event
  
 
namespace  mod_book\output
  
 
namespace  mod_book\plugininfo
  
 
namespace  mod_book\privacy
  
 
namespace  mod_book\search
  
 

Classes

class  backup_book_activity_structure_step
 Structure step to backup one book activity. More...
 
class  backup_book_activity_task
 
class  behat_mod_book_generator
 Behat data generator for mod_book. More...
 
class  book_chapter_edit_form
 
class  book_file_info
 File browsing support class. More...
 
class  mod_book\analytics\indicator\activity_base
 Activity base class. More...
 
class  mod_book\analytics\indicator\cognitive_depth
 Cognitive depth indicator - book. More...
 
class  mod_book\analytics\indicator\social_breadth
 Social breadth indicator - book. More...
 
class  mod_book\event\chapter_created
 The mod_book chapter created event class. More...
 
class  mod_book\event\chapter_deleted
 The mod_book chapter deleted event class. More...
 
class  mod_book\event\chapter_updated
 The mod_book chapter updated event class. More...
 
class  mod_book\event\chapter_viewed
 The mod_book chapter viewed event class. More...
 
class  mod_book\event\course_module_instance_list_viewed
 The mod_book instance list viewed event class. More...
 
class  mod_book\event\course_module_viewed
 The mod_book course module viewed event class. More...
 
class  mod_book\helper
 
class  mod_book\output\main_action_menu
 Output the action menu for the book activity. More...
 
class  mod_book\output\renderer
 Moodle renderer used to display special elements of the book module. More...
 
class  mod_book\plugininfo\booktool
 
class  mod_book\privacy\provider
 The mod_book module does not store any data. More...
 
class  mod_book\search\activity
 Search area for mod_book activities. More...
 
class  mod_book\search\chapter
 Search area for mod_book chapters. More...
 
class  mod_book_external
 Book external functions. More...
 
class  mod_book_generator
 mod_book data generator class. More...
 
class  mod_book_mod_form
 
class  moodle1_mod_book_handler
 Book conversion handler. More...
 
class  restore_book_activity_structure_step
 Structure step to restore one book activity. More...
 
class  restore_book_activity_task
 

Functions

 book_add_fake_block ($chapters, $chapter, $book, $cm, $edit=null)
 Add the book TOC sticky block to the default region.
 
 book_add_instance ($data, $mform)
 Add book instance.
 
 book_check_updates_since (cm_info $cm, $from, $filter=array())
 Check if the module has any update that affects the current user since a given time.
 
 book_cron ()
 No cron in book.
 
 book_delete_instance ($id)
 Delete book instance by activity id.
 
 book_export_contents ($cm, $baseurl)
 Export book resource contents.
 
 book_extend_settings_navigation (settings_navigation $settingsnav, navigation_node $booknode)
 Adds module specific settings to the settings block.
 
 book_get_chapter_title ($chid, $chapters, $book, $context)
 Returns the title for a given chapter.
 
 book_get_file_areas ($course, $cm, $context)
 Lists all browsable file areas.
 
 book_get_file_info ($browser, $areas, $course, $cm, $context, $filearea, $itemid, $filepath, $filename)
 File browsing support for book module chapter area.
 
 book_get_nav_classes ()
 Returns list of available navigation link CSS classes.
 
 book_get_nav_types ()
 
 book_get_numbering_types ()
 Returns list of available numbering types.
 
 book_get_post_actions ()
 Return write actions.
 
 book_get_toc ($chapters, $chapter, $book, $cm, $edit)
 Generate toc structure.
 
 book_get_view_actions ()
 Return read actions.
 
 book_grades ($bookid)
 No grading in book.
 
 book_page_type_list ($pagetype, $parentcontext, $currentcontext)
 Return a list of page types.
 
 book_pluginfile ($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array())
 Serves the book attachments.
 
 book_preload_chapters ($book)
 Preload book chapters and fix toc structure if necessary.
 
 book_print_recent_activity ($course, $viewfullnames, $timestart)
 Given a course and a time, this module should find recent activity that has occurred in book activities and print it out.
 
 book_reset_course_form_definition (&$mform)
 The elements to add the course reset form.
 
 book_reset_userdata ($data)
 This function is used by the reset_course_userdata function in moodlelib.
 
 book_scale_used ()
 
 book_scale_used_anywhere ($scaleid)
 Checks if scale is being used by any instance of book.
 
 book_supports ($feature)
 Supported features.
 
 book_update_instance ($data, $mform)
 Update book instance.
 
 book_view ($book, $chapter, $islastchapter, $course, $cm, $context)
 Mark the activity completed (if required) and trigger the course_module_viewed event.
 
 mod_book_core_calendar_provide_event_action (calendar_event $event, core_calendar\action_factory $factory, int $userid=0)
 This function receives a calendar event and returns the action associated with it, or null if there is none.
 
 mod_book_get_fontawesome_icon_map ()
 Get icon mapping for font-awesome.
 
 mod_book_get_tagged_chapters ($tag, $exclusivemode=false, $fromctx=0, $ctx=0, $rec=true, $page=0)
 Returns book chapters tagged with a specified tag.
 
 xmldb_book_upgrade ($oldversion)
 Book module upgrade task.
 

Variables

 $capabilities
 
 $functions
 
 $logs
 
 $plugin = 2024041600
 
 $tagareas
 
const BOOK_NUM_BULLETS '2'
 
const BOOK_NUM_INDENTED '3'
 
const BOOK_NUM_NONE '0'
 The following defines are used to define how the chapters and subchapters of a book should be displayed in that table of contents.
 
const BOOK_NUM_NUMBERS '1'
 
$plugin component = 'mod_book'
 
$plugin cron = 0
 
$plugin version = 2024042200
 

Detailed Description

Function Documentation

◆ book_add_fake_block()

book_add_fake_block ( $chapters,
$chapter,
$book,
$cm,
$edit = null )

Add the book TOC sticky block to the default region.

Parameters
array$chaptersThe Chapters in the book
stdClass$chapterThe current chapter
stdClass$bookThe book
stdClass$cmThe course module
bool | null$editWhether the user is editing

◆ book_add_instance()

book_add_instance ( $data,
$mform )

Add book instance.

Parameters
stdClass$data
stdClass$mform
Return values
intnew book instance id

◆ book_check_updates_since()

book_check_updates_since ( cm_info $cm,
$from,
$filter = array() )

Check if the module has any update that affects the current user since a given time.

Parameters
cm_info$cmcourse module data
int$fromthe time to check updates from
array$filterif we need to check only specific updates
Return values
stdClassan object with the different type of areas indicating if they were updated or not
Since
Moodle 3.2

◆ book_cron()

book_cron ( )

No cron in book.

Return values
bool

◆ book_delete_instance()

book_delete_instance ( $id)

Delete book instance by activity id.

Parameters
int$id
Return values
boolsuccess

◆ book_export_contents()

book_export_contents ( $cm,
$baseurl )

Export book resource contents.

Parameters
stdClass$cmCourse module object
string$baseurlBase URL for file downloads
Return values
arrayof file content

◆ book_extend_settings_navigation()

book_extend_settings_navigation ( settings_navigation $settingsnav,
navigation_node $booknode )

Adds module specific settings to the settings block.

Parameters
settings_navigation$settingsnavThe settings navigation object
navigation_node$booknodeThe node to add module settings to
Return values
void

◆ book_get_chapter_title()

book_get_chapter_title ( $chid,
$chapters,
$book,
$context )

Returns the title for a given chapter.

Parameters
int$chid
array$chapters
stdClass$book
context_module$context
Return values
string

◆ book_get_file_areas()

book_get_file_areas ( $course,
$cm,
$context )

Lists all browsable file areas.

Parameters
object$course
object$cm
object$context
Return values
array

◆ book_get_file_info()

book_get_file_info ( $browser,
$areas,
$course,
$cm,
$context,
$filearea,
$itemid,
$filepath,
$filename )

File browsing support for book module chapter area.

Parameters
object$browser
object$areas
object$course
object$cm
object$context
string$filearea
int$itemid
string$filepath
string$filename
Return values
objectfile_info instance or null if not found

◆ book_get_nav_classes()

book_get_nav_classes ( )

Returns list of available navigation link CSS classes.

Deprecated
since Moodle 4.4.
Todo
MDL-81328 Final deprecation in Moodle 4.8.
Return values
array

◆ book_get_nav_types()

book_get_nav_types ( )
Deprecated
since Moodle 4.0

◆ book_get_numbering_types()

book_get_numbering_types ( )

Returns list of available numbering types.

Return values
array

◆ book_get_post_actions()

book_get_post_actions ( )

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 values
array

◆ book_get_toc()

book_get_toc ( $chapters,
$chapter,
$book,
$cm,
$edit )

Generate toc structure.

Parameters
array$chapters
stdClass$chapter
stdClass$book
stdClass$cm
bool$edit
Return values
string

◆ book_get_view_actions()

book_get_view_actions ( )

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 values
array

◆ book_grades()

book_grades ( $bookid)

No grading in book.

Parameters
int$bookid
Return values
null

◆ book_page_type_list()

book_page_type_list ( $pagetype,
$parentcontext,
$currentcontext )

Return a list of page types.

Parameters
string$pagetypecurrent page type
stdClass$parentcontextBlock's parent context
stdClass$currentcontextCurrent context of block
Return values
array

◆ book_pluginfile()

book_pluginfile ( $course,
$cm,
$context,
$filearea,
$args,
$forcedownload,
array $options = array() )

Serves the book attachments.

Implements needed access control ;-)

Parameters
stdClass$coursecourse object
cm_info$cmcourse module object
context$contextcontext object
string$fileareafile area
array$argsextra arguments
bool$forcedownloadwhether or not force download
array$optionsadditional options affecting the file serving
Return values
boolfalse if file not found, does not return if found - just send the file

◆ book_preload_chapters()

book_preload_chapters ( $book)

Preload book chapters and fix toc structure if necessary.

Returns array of chapters with standard 'pagenum', 'id, pagenum, subchapter, title, content, contentformat, hidden' and extra 'parent, number, subchapters, prev, next'. Please note the content/text of chapters is not included.

Parameters
stdClass$book
Return values
arrayof id=>chapter

◆ book_print_recent_activity()

book_print_recent_activity ( $course,
$viewfullnames,
$timestart )

Given a course and a time, this module should find recent activity that has occurred in book activities and print it out.

Parameters
stdClass$course
bool$viewfullnames
int$timestart
Return values
booltrue if there was output, or false is there was none

◆ book_reset_course_form_definition()

book_reset_course_form_definition ( & $mform)

The elements to add the course reset form.

Parameters
MoodleQuickForm$mform

◆ book_reset_userdata()

book_reset_userdata ( $data)

This function is used by the reset_course_userdata function in moodlelib.

Parameters
$datathe data submitted from the reset course.
Return values
arraystatus array

◆ book_scale_used()

book_scale_used ( )
Deprecated
since Moodle 3.8

◆ book_scale_used_anywhere()

book_scale_used_anywhere ( $scaleid)

Checks if scale is being used by any instance of book.

This is used to find out if scale used anywhere

Parameters
int$scaleid
Return values
booltrue if the scale is used by any book

◆ book_supports()

book_supports ( $feature)

Supported features.

Parameters
string$featureFEATURE_xx constant for requested feature
Return values
mixedTrue if module supports feature, false if not, null if doesn't know or string for the module purpose.

◆ book_update_instance()

book_update_instance ( $data,
$mform )

Update book instance.

Parameters
stdClass$data
stdClass$mform
Return values
booltrue

◆ book_view()

book_view ( $book,
$chapter,
$islastchapter,
$course,
$cm,
$context )

Mark the activity completed (if required) and trigger the course_module_viewed event.

Parameters
stdClass$bookbook object
stdClass$chapterchapter object
bool$islaschapteris the las chapter of the book?
stdClass$coursecourse object
stdClass$cmcourse module object
stdClass$contextcontext object
Since
Moodle 3.0

◆ mod_book_core_calendar_provide_event_action()

mod_book_core_calendar_provide_event_action ( calendar_event $event,
core_calendar\action_factory $factory,
int $userid = 0 )

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.

Parameters
calendar_event$event
core_calendar\action_factory$factory
int$useridUser id to use for all capability checks, etc. Set to 0 for current user (default).
Return values
core_calendar\local\event\entities\action_interface|null

◆ mod_book_get_tagged_chapters()

mod_book_get_tagged_chapters ( $tag,
$exclusivemode = false,
$fromctx = 0,
$ctx = 0,
$rec = true,
$page = 0 )

Returns book chapters tagged with a specified tag.

This is a callback used by the tag area mod_book/book_chapters to search for book chapters tagged with a specific tag.

Parameters
core_tag_tag$tag
bool$exclusivemodeif set to true it means that no other entities tagged with this tag are displayed on the page and the per-page limit may be bigger
int$fromctxcontext id where the link was displayed, may be used by callbacks to display items in the same context first
int$ctxcontext id where to search for records
bool$recsearch in subcontexts as well
int$page0-based number of page being displayed
Return values
core_tag\output\tagindex

◆ xmldb_book_upgrade()

xmldb_book_upgrade ( $oldversion)

Book module upgrade task.

Parameters
int$oldversionthe version we are upgrading from
Return values
boolalways true

Variable Documentation

◆ $functions

$functions
Initial value:
= array(
'mod_book_view_book' => array(
'classname' => 'mod_book_external',
'methodname' => 'view_book',
'description' => 'Simulate the view.php web interface book: trigger events, completion, etc...',
'type' => 'write',
'capabilities' => 'mod/book:read',
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
),
'mod_book_get_books_by_courses' => array(
'classname' => 'mod_book_external',
'methodname' => 'get_books_by_courses',
'description' => 'Returns a list of book instances in a provided set of courses,
if no courses are provided then all the book instances the user has access to will be returned.',
'type' => 'read',
'capabilities' => '',
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE)
)
)
const MOODLE_OFFICIAL_MOBILE_SERVICE
Moodle mobile app service name.
Definition moodlelib.php:555

◆ $logs

$logs
Initial value:
= array(
array('module' => 'book', 'action' => 'add', 'mtable' => 'book', 'field' => 'name'),
array('module' => 'book', 'action' => 'update', 'mtable' => 'book', 'field' => 'name'),
array('module' => 'book', 'action' => 'view', 'mtable' => 'book', 'field' => 'name'),
array('module' => 'book', 'action' => 'add chapter', 'mtable' => 'book_chapters', 'field' => 'title'),
array('module' => 'book', 'action' => 'update chapter', 'mtable'=> 'book_chapters', 'field' => 'title'),
array('module' => 'book', 'action' => 'view chapter', 'mtable' => 'book_chapters', 'field' => 'title')
)

◆ $tagareas

$tagareas
Initial value:
= array(
array(
'itemtype' => 'book_chapters',
'component' => 'mod_book',
'callback' => 'mod_book_get_tagged_chapters',
'callbackfile' => '/mod/book/locallib.php',
),
)

◆ BOOK_NUM_NONE

const BOOK_NUM_NONE '0'

The following defines are used to define how the chapters and subchapters of a book should be displayed in that table of contents.

BOOK_NUM_NONE No special styling will applied and the editor will be able to do what ever thay want in the title BOOK_NUM_NUMBERS Chapters and subchapters are numbered (1, 1.1, 1.2, 2, ...) BOOK_NUM_BULLETS Subchapters are indented and displayed with bullets BOOK_NUM_INDENTED Subchapters are indented