Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
datalib.php File Reference

Functions

object _fix_course_cats ($children, &$sortorder, $parent, $depth, $path, &$fixcontexts)
 Internal recursive category verification function, do not use directly!
 
moodle_database add_to_config_log ($name, $oldvalue, $value, $plugin)
 Add an entry to the config log table.
 
 decompose_update_into_safe_changes (array $newvalues, $unusedvalue)
 Helper used by update_field_with_unique_index().
 
object fix_course_sortorder ()
 Fixes course category and course sortorder, also verifies category and course parents and paths.
 
 get_admin ()
 Returns $user object of the main admin user.
 
 get_admins ()
 Returns list of all admins, using 1 DB query.
 
 get_all_instances_in_course ($modulename, $course, $userid=NULL, $includeinvisible=false)
 Returns an array of all the active instances of a particular module in a given course, sorted in the order they are defined.
 
object get_all_instances_in_courses ($modulename, $courses, $userid=NULL, $includeinvisible=false)
 Returns an array of all the active instances of a particular module in given courses, sorted in the order they are defined.
 
 get_course ($courseid, $clone=true)
 Gets a course object from database.
 
object get_course_mods ($courseid)
 MODULE FUNCTIONS /////////////////////////////////////////////////.
 
object get_coursemodule_from_id ($modulename, $cmid, $courseid=0, $sectionnum=false, $strictness=IGNORE_MISSING)
 Given an id of a course module, finds the coursemodule description.
 
object get_coursemodule_from_instance ($modulename, $instance, $courseid=0, $sectionnum=false, $strictness=IGNORE_MISSING)
 Given an instance number of a module, finds the coursemodule description.
 
 get_coursemodules_in_course ($modulename, $courseid, $extrafields='')
 Returns all course modules of given activity in course.
 
object get_courses ($categoryid="all", $sort="c.sortorder ASC", $fields="c.*")
 Returns list of courses, for whole site, or category.
 
object get_courses_search ($searchterms, $sort, $page, $recordsperpage, &$totalcount, $requiredcapabilities=array(), $searchcond=[], $params=[])
 A list of courses that match a search.
 
 get_log_manager ($forcereload=false)
 LOG FUNCTIONS /////////////////////////////////////////////////////.
 
 get_max_courses_in_category ()
 Return maximum number of courses in a category.
 
object get_my_remotecourses ($userid=0)
 List of remote courses that a user has access to via MNET.
 
object get_my_remotehosts ()
 List of remote hosts that a user has access to via MNET.
 
 get_safe_orderby (array $orderbymap, string $orderbykey, string $direction='', bool $useprefix=true)
 Prepare a safe ORDER BY statement from user interactable requests.
 
 get_safe_orderby_multiple (array $orderbymap, array $orderbykeys, array $directions=[])
 Prepare a safe ORDER BY statement from user interactable requests using multiple values.
 
object get_scales_menu ($courseid=0)
 Returns a menu of all available scales from the site as well as the given course.
 
 get_site ()
 OTHER SITE AND COURSE FUNCTIONS /////////////////////////////////////////////.
 
object get_users ($get=true, $search='', $confirmed=false, array $exceptions=null, $sort='firstname ASC', $firstinitial='', $lastinitial='', $page='', $recordsperpage='', $fields=' *', $extraselect='', array $extraparams=null)
 Returns a subset of users.
 
object get_users_confirmed ()
 Full list of users that have confirmed their accounts.
 
 get_users_listing ($sort='lastaccess', $dir='ASC', $page=0, $recordsperpage=0, $search='', $firstinitial='', $lastinitial='', $extraselect='', array $extraparams=null, $extracontext=null)
 Return filtered (if provided) list of users in site, except guest and deleted users.
 
 increment_revision_number ($table, $field, $select, array $params=null)
 Increment standard revision field.
 
object instance_is_visible ($moduletype, $module)
 Determine whether a module instance is visible within a course.
 
 print_object ($item, array $expandclasses=['/./'], bool $textonly=false, bool $return=false, int $depth=0, array $done=[])
 GENERAL HELPFUL THINGS ///////////////////////////////////.
 
object search_users ($courseid, $groupid, $searchtext, $sort='', array $exceptions=null)
 Search through course users.
 
 update_field_with_unique_index ($table, $field, array $newvalues, array $otherconditions, $unusedvalue=-1)
 This method can update the values in mulitple database rows for a colum with a unique index, without violating that constraint.
 
stdClass user_accesstime_log ($courseid=0)
 Store user last access times - called when use enters a course or site.
 
object user_can_create_courses ()
 @uses CONTEXT_COURSECAT
 
 users_order_by_sql (string $usertablealias='', string $search=null, context $context=null, array $customfieldmappings=[])
 This function generates the standard ORDER BY clause for use when generating lists of users.
 
 users_search_sql (string $search, string $u='u', int $searchtype=USER_SEARCH_STARTS_WITH, array $extrafields=[], array $exclude=null, array $includeonly=null)
 Returns SQL used to search through user table to find users (in a query which may also join and apply other conditions).
 
 xmldb_debug ($message, $object)
 This function is the official hook inside XMLDB stuff to delegate its debug to one external function.
 

Variables

const MAX_COURSE_CATEGORIES 10000
 The maximum number of course categories MAX_COURSES_IN_CATEGORY * MAX_COURSE_CATEGORIES must not be more than max integer!
 
const MAX_COURSES_IN_CATEGORY 10000
 The maximum courses in a category MAX_COURSES_IN_CATEGORY * MAX_COURSE_CATEGORIES must not be more than max integer!
 
const USER_SEARCH_CONTAINS 1
 
const USER_SEARCH_EXACT_MATCH 2
 
const USER_SEARCH_STARTS_WITH (!defined('LASTACCESS_UPDATE_SECS')) 0
 Number of seconds to wait before updating lastaccess information in DB.