Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Files | Namespaces | Classes | Functions | Variables
mod_book

Files

file  access.php
 Book module capability definition.
 
file  activity.php
 Search area for mod_book activities.
 
file  activity_base.php
 Activity base class.
 
file  backup_book_activity_task.class.php
 Description of book backup task.
 
file  backup_book_settingslib.php
 Description of book backup settings.
 
file  backup_book_stepslib.php
 Define all the backup steps that will be used by the backup_book_activity_task.
 
file  behat_mod_book_generator.php
 Behat data generator for mod_book.
 
file  booktool.php
 Subplugin info class.
 
file  chapter.php
 Search area for mod_book chapters.
 
file  chapter_created.php
 The mod_book chapter created event.
 
file  chapter_deleted.php
 The mod_book chapter deleted event.
 
file  chapter_updated.php
 The mod_book chapter updated event.
 
file  chapter_viewed.php
 The mod_book chapter viewed event.
 
file  cognitive_depth.php
 Cognitive depth indicator - book.
 
file  course_module_instance_list_viewed.php
 The mod_book instance list viewed event.
 
file  course_module_viewed.php
 The mod_book course module viewed event.
 
file  edit_form.php
 Chapter edit form.
 
file  external.php
 Book external API.
 
file  lib.php
 Provides support for the conversion of moodle1 backup to the moodle2 format.
 
file  lib.php
 Book module core interaction API.
 
file  lib.php
 mod_book data generator.
 
file  locallib.php
 Book module local lib functions.
 
file  log.php
 Book module log events definition.
 
file  mod_form.php
 Instance add/edit form.
 
file  provider.php
 Privacy Subsystem implementation for mod_book.
 
file  restore_book_activity_task.class.php
 Description of book restore task.
 
file  restore_book_stepslib.php
 Define all the restore steps that will be used by the restore_book_activity_task.
 
file  services.php
 Book external functions and service definitions.
 
file  settings.php
 Book plugin settings.
 
file  social_breadth.php
 Social breadth indicator - book.
 
file  tag.php
 Tag areas in component mod_book.
 
file  upgrade.php
 Book module upgrade code.
 
file  version.php
 Book plugin version info.
 

Namespaces

namespace  mod_book\analytics\indicator
  
 
namespace  mod_book\event
  
 
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\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
 
class  mod_book_generator
 
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. More...
 
 book_add_instance ($data, $mform)
 Add book instance. More...
 
 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. More...
 
 book_cron ()
 No cron in book. More...
 
 book_delete_instance ($id)
 Delete book instance by activity id. More...
 
 book_export_contents ($cm, $baseurl)
 Export book resource contents. More...
 
 book_extend_settings_navigation (settings_navigation $settingsnav, navigation_node $booknode)
 Adds module specific settings to the settings block. More...
 
 book_get_chapter_title ($chid, $chapters, $book, $context)
 Returns the title for a given chapter. More...
 
 book_get_file_areas ($course, $cm, $context)
 Lists all browsable file areas. More...
 
 book_get_file_info ($browser, $areas, $course, $cm, $context, $filearea, $itemid, $filepath, $filename)
 File browsing support for book module chapter area. More...
 
 book_get_nav_classes ()
 Returns list of available navigation link CSS classes. More...
 
 book_get_nav_types ()
 Returns list of available navigation link types. More...
 
 book_get_numbering_types ()
 Returns list of available numbering types. More...
 
 book_get_post_actions ()
 Return write actions. More...
 
 book_get_toc ($chapters, $chapter, $book, $cm, $edit)
 Generate toc structure. More...
 
 book_get_view_actions ()
 Return read actions. More...
 
 book_grades ($bookid)
 No grading in book. More...
 
 book_page_type_list ($pagetype, $parentcontext, $currentcontext)
 Return a list of page types. More...
 
 book_pluginfile ($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array())
 Serves the book attachments. More...
 
 book_preload_chapters ($book)
 Preload book chapters and fix toc structure if necessary. More...
 
 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. More...
 
 book_reset_course_form_definition (&$mform)
 The elements to add the course reset form. More...
 
 book_reset_userdata ($data)
 This function is used by the reset_course_userdata function in moodlelib. More...
 
 book_scale_used ()
 
 book_scale_used_anywhere ($scaleid)
 Checks if scale is being used by any instance of book. More...
 
 book_supports ($feature)
 Supported features. More...
 
 book_update_instance ($data, $mform)
 Update book instance. More...
 
 book_view ($book, $chapter, $islastchapter, $course, $cm, $context)
 Mark the activity completed (if required) and trigger the course_module_viewed event. More...
 
 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. More...
 
 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. More...
 
 xmldb_book_upgrade ($oldversion)
 Book module upgrade task. More...
 

Variables

 $capabilities
 
 $functions
 
 $logs
 
 $plugin = 2020060900
 
 $tagareas
 
const BOOK_LINK_IMAGE '1'
 
const BOOK_LINK_TEXT '2'
 
const BOOK_LINK_TOCONLY '0'
 The following defines are used to define the navigation style used within a book. More...
 
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. More...
 
const BOOK_NUM_NUMBERS '1'
 
$plugin component = 'mod_book'
 
$plugin cron = 0
 
$plugin version = 2020061500
 

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.

Return values
array

◆ book_get_nav_types()

book_get_nav_types ( )

Returns list of available navigation link types.

Return values
array

◆ 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
moodleform$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

◆ 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:501

◆ $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_LINK_TOCONLY

const BOOK_LINK_TOCONLY '0'

The following defines are used to define the navigation style used within a book.

BOOK_LINK_TOCONLY Only the table of contents is shown, in a side region. BOOK_LINK_IMAGE Arrows link to previous/next/exit pages, in addition to the TOC. BOOK_LINK_TEXT Page names and arrows link to previous/next/exit pages, in addition to the TOC.

◆ 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