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

Library of functions and constants for notes

Copyright: 2007 onwards Yu Zhang
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 416 lines (14 kb)
Included or required: 3 times
Referenced: 3 times
Includes or requires: 0 files

Defines 13 functions


Functions that are not part of a class:

note_list($courseid=0, $userid=0, $state = '', $author = 0, $order='lastmodified DESC', $limitfrom=0, $limitnum=0)   X-Ref
Retrieves a list of note objects with specific atributes.

return: array of note objects
param: int    $courseid id of the course in which the notes were posted (0 means any)
param: int    $userid id of the user to which the notes refer (0 means any)
param: string $state state of the notes (i.e. draft, public, site) ('' means any)
param: int    $author id of the user who modified the note last time (0 means any)
param: string $order an order to sort the results in
param: int    $limitfrom number of records to skip (offset)
param: int    $limitnum number of records to fetch

note_load($noteid)   X-Ref
Retrieves a note object based on its id.

return: stdClass object
param: int $noteid ID of the note to retrieve

note_save(&$note)   X-Ref
Saves a note object. The note object is passed by reference and its fields (i.e. id)
might change during the save.

return: boolean true if the object was saved; false otherwise
param: stdClass   $note object to save

note_delete($note)   X-Ref
Deletes a note object based on its id.

return: boolean true always
param: int|object    $note id of the note to delete, or a note object which is to be deleted.

note_get_state_name($state)   X-Ref
Converts a state value to its corespondent name

return: string corespondent state name
param: string  $state state value to convert

note_get_state_names()   X-Ref
Returns an array of mappings from state values to state names

return: array of mappings

note_print($note, $detail = NOTES_SHOW_FULL)   X-Ref
Prints a note object

param: note  $note the note object to print
param: int   $detail OR-ed NOTES_SHOW_xyz flags that specify which note parts to print

note_print_list($notes, $detail = NOTES_SHOW_FULL)   X-Ref
Prints a list of note objects

param: array  $notes array of note objects to print
param: int   $detail OR-ed NOTES_SHOW_xyz flags that specify which note parts to print

note_print_notes($header, $addcourseid = 0, $viewnotes = true, $courseid = 0, $userid = 0, $state = '', $author = 0)   X-Ref
Retrieves and prints a list of note objects with specific atributes.

param: string  $header HTML to print above the list
param: int     $addcourseid id of the course for the add notes link (0 hide link)
param: boolean $viewnotes true if the notes should be printed; false otherwise (print notesnotvisible string)
param: int     $courseid id of the course in which the notes were posted (0 means any)
param: int     $userid id of the user to which the notes refer (0 means any)
param: string  $state state of the notes (i.e. draft, public, site) ('' means any)
param: int     $author id of the user who modified the note last time (0 means any)

note_delete_all($courseid)   X-Ref
Delete all notes about users in course-

return: bool success
param: int $courseid

note_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

note_view($context, $userid)   X-Ref
Trigger notes viewed event

param: stdClass $context context object
param: int $userid  user id (the user we are viewing the notes)

core_notes_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course)   X-Ref
Add nodes to myprofile page.

return: bool
param: \core_user\output\myprofile\tree $tree Tree object
param: stdClass $user user object
param: bool $iscurrentuser
param: stdClass $course Course object