Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
/mod/wiki/ -> lib.php (source)

Differences Between: [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403] [Versions 39 and 310]

Library of functions and constants for module wiki It contains the great majority of functions defined by Moodle that are mandatory to develop a module.

Author: Jordi Piguillem
Author: Marc Alier
Author: David Jimenez
Author: Josep Arus
Author: Kenneth Riba
Copyright: 2009 Marc Alier, Jordi Piguillem marc.alier@upc.edu
Copyright: 2009 Universitat Politecnica de Catalunya http://www.upc.edu
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 848 lines (29 kb)
Included or required: 2 times
Referenced: 7 times
Includes or requires: 0 files

Defines 23 functions


Functions that are not part of a class:

wiki_add_instance($wiki)   X-Ref
Given an object containing all the necessary data,
(defined by the form in mod.html) this function
will create a new instance and return the id number
of the new instance.

param: object $instance An object from the form in mod.html
return: int The id of the newly inserted wiki record

wiki_update_instance($wiki)   X-Ref
Given an object containing all the necessary data,
(defined by the form in mod.html) this function
will update an existing instance with new data.

param: object $instance An object from the form in mod.html
return: boolean Success/Fail

wiki_delete_instance($id)   X-Ref
Given an ID of an instance of this module,
this function will permanently delete the instance
and any data that depends on it.

param: int $id Id of the module instance
return: boolean Success/Failure

wiki_reset_userdata($data)   X-Ref
Implements callback to reset course

param: stdClass $data
return: boolean|array

wiki_reset_course_form_definition(&$mform)   X-Ref
No description

wiki_supports($feature)   X-Ref
Indicates API features that the wiki supports.

param: string $feature
return: mixed True if yes (some features may use other values)

wiki_print_recent_activity($course, $viewfullnames, $timestart)   X-Ref
Given a course and a time, this module should find recent activity
that has occurred in wiki activities and print it out.
Return true if there was output, or false is there was none.

param: object $course
param: bool $viewfullnames capability
param: int $timestart
return: boolean

wiki_grades($wikiid)   X-Ref
Must return an array of grades for a given instance of this module,
indexed by user.  It also returns a maximum allowed grade.

Example:
$return->grades = array of grades;
$return->maxgrade = maximum allowed grade;

return $return;

param: int $wikiid ID of an instance of this module
return: mixed Null or object with an array of grades and with the maximum grade

wiki_scale_used()   X-Ref


wiki_scale_used_anywhere($scaleid)   X-Ref
Checks if scale is being used by any instance of wiki.
This function was added in 1.9

This is used to find out if scale used anywhere
param: $scaleid int
return: boolean True if the scale is used by any wiki

wiki_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options=array()   X-Ref
file serving callback

param: stdClass $course course object
param: stdClass $cm course module object
param: stdClass $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 the file was not found, just send the file otherwise and do not return anything

wiki_search_form($cm, $search = '', $subwiki = null)   X-Ref
Search for wiki

param: stdClass $cm course module object
param: string $search searchword.
param: stdClass $subwiki Optional Subwiki.
return: Search wiki input form

wiki_extend_navigation(navigation_node $navref, $course, $module, $cm)   X-Ref
No description

wiki_get_extra_capabilities()   X-Ref
Returns all other caps used in wiki module

return: array

wiki_comment_permissions($comment_param)   X-Ref
Running addtional permission check on plugin, for example, plugins
may have switch to turn on/off comments option, this callback will
affect UI display, not like pluginname_comment_validate only throw
exceptions.
Capability check has been done in comment->check_permissions(), we
don't need to do it again here.

param: stdClass $comment_param {
return: array

wiki_comment_validate($comment_param)   X-Ref
Validate comment parameter before perform other comments actions

param: stdClass $comment_param {
return: boolean

wiki_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

wiki_view($wiki, $course, $cm, $context)   X-Ref
Mark the activity completed (if required) and trigger the course_module_viewed event.

param: stdClass $wiki       Wiki object.
param: stdClass $course     Course object.
param: stdClass $cm         Course module object.
param: stdClass $context    Context object.

wiki_page_view($wiki, $page, $course, $cm, $context, $uid = null, $other = null, $subwiki = null)   X-Ref
Mark the activity completed (if required) and trigger the page_viewed event.

param: stdClass $wiki       Wiki object.
param: stdClass $page       Page object.
param: stdClass $course     Course object.
param: stdClass $cm         Course module object.
param: stdClass $context    Context object.
param: int $uid             Optional User ID.
param: array $other         Optional Other params: title, wiki ID, group ID, groupanduser, prettyview.
param: stdClass $subwiki    Optional Subwiki.

wiki_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_wiki_get_fontawesome_icon_map()   X-Ref
Get icon mapping for font-awesome.


mod_wiki_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

wiki_cm_info_dynamic(cm_info $cm)   X-Ref
Sets dynamic information about a course module

This callback is called from cm_info when checking module availability (incl. $cm->uservisible)

Main viewing capability in mod_wiki is 'mod/wiki:viewpage' instead of the expected standardised 'mod/wiki:view'.
The method cm_info::is_user_access_restricted_by_capability() does not work for wiki, we need to implement
this callback.

param: cm_info $cm