|
Moodle
2.2.1
http://www.collinsharper.com
|
Go to the source code of this file.
Namespaces | |
| namespace | core |
Enumerations | |
| enum | MAX_COURSES_IN_CATEGORY |
| enum | MAX_COURSE_CATEGORIES |
| enum | LASTACCESS_UPDATE_SECS |
Functions | |
| get_admins () | |
| search_users ($courseid, $groupid, $searchtext, $sort='', array $exceptions=null) | |
| get_users ($get=true, $search='', $confirmed=false, array $exceptions=null, $sort='firstname ASC', $firstinitial='', $lastinitial='', $page='', $recordsperpage='', $fields='*', $extraselect='', array $extraparams=null) | |
| get_users_listing ($sort='lastaccess', $dir='ASC', $page=0, $recordsperpage=0, $search='', $firstinitial='', $lastinitial='', $extraselect='', array $extraparams=null, $extracontext=null) | |
| get_users_confirmed () | |
| get_site () | |
| OTHER SITE AND COURSE FUNCTIONS /////////////////////////////////////////////. | |
| get_courses ($categoryid="all", $sort="c.sortorder ASC", $fields="c.*") | |
| get_courses_page ($categoryid="all", $sort="c.sortorder ASC", $fields="c.*", &$totalcount, $limitfrom="", $limitnum="") | |
| get_courses_wmanagers ($categoryid=0, $sort="c.sortorder ASC", $fields=array()) | |
| get_courses_search ($searchterms, $sort='fullname ASC', $page=0, $recordsperpage=50, &$totalcount) | |
| get_categories ($parent='none', $sort=NULL, $shallow=true) | |
| get_all_subcategories ($catid) | |
| get_course_category ($catid=0) | |
| fix_course_sortorder () | |
| _fix_course_cats ($children, &$sortorder, $parent, $depth, $path, &$fixcontexts) | |
| get_my_remotecourses ($userid=0) | |
| get_my_remotehosts () | |
| make_default_scale () | |
| get_scales_menu ($courseid=0) | |
| update_timezone_records ($timezones) | |
| get_course_mods ($courseid) | |
| MODULE FUNCTIONS /////////////////////////////////////////////////. | |
| get_coursemodule_from_id ($modulename, $cmid, $courseid=0, $sectionnum=false, $strictness=IGNORE_MISSING) | |
| get_coursemodule_from_instance ($modulename, $instance, $courseid=0, $sectionnum=false, $strictness=IGNORE_MISSING) | |
| get_coursemodules_in_course ($modulename, $courseid, $extrafields='') | |
| get_all_instances_in_courses ($modulename, $courses, $userid=NULL, $includeinvisible=false) | |
| get_all_instances_in_course ($modulename, $course, $userid=NULL, $includeinvisible=false) | |
| instance_is_visible ($moduletype, $module) | |
| coursemodule_visible_for_user ($cm, $userid=0) | |
| add_to_log ($courseid, $module, $action, $url='', $info='', $cm=0, $user=0) | |
| LOG FUNCTIONS /////////////////////////////////////////////////////. | |
| user_accesstime_log ($courseid=0) | |
| get_logs ($select, array $params=null, $order='l.time DESC', $limitfrom='', $limitnum='', &$totalcount) | |
| get_logs_usercourse ($userid, $courseid, $coursestart) | |
| get_logs_userday ($userid, $courseid, $daystart) | |
| count_login_failures ($mode, $username, $lastlogin) | |
| print_object ($object) | |
| GENERAL HELPFUL THINGS ///////////////////////////////////. | |
| xmldb_debug ($message, $object) | |
| user_can_create_courses () | |
Number of seconds to wait before updating lastaccess information in DB.
Definition at line 48 of file datalib.php.
The maximum number of course categories MAX_COURSES_IN_CATEGORY * MAX_COURSE_CATEGORIES must not be more than max integer!
Definition at line 43 of file datalib.php.
The maximum courses in a category MAX_COURSES_IN_CATEGORY * MAX_COURSE_CATEGORIES must not be more than max integer!
Definition at line 37 of file datalib.php.
| _fix_course_cats | ( | $ | children, |
| &$ | sortorder, | ||
| $ | parent, | ||
| $ | depth, | ||
| $ | path, | ||
| &$ | fixcontexts | ||
| ) |
Internal recursive category verification function, do not use directly!
object MAX_COURSES_IN_CATEGORY CONTEXT_COURSECAT
| array | $children | |
| int | $sortorder | |
| string | $parent | |
| int | $depth | |
| string | $path | |
| array | $fixcontexts |
Definition at line 1167 of file datalib.php.


| add_to_log | ( | $ | courseid, |
| $ | module, | ||
| $ | action, | ||
| $ | url = '', |
||
| $ | info = '', |
||
| $ | cm = 0, |
||
| $ | user = 0 |
||
| ) |
LOG FUNCTIONS /////////////////////////////////////////////////////.
Add an entry to the log table.
Add an entry to the log table. These are "action" focussed rather than web server hits, and provide a way to easily reconstruct what any particular student has been doing.
object object object SITEID DEBUG_DEVELOPER DEBUG_ALL
| int | $courseid | The course id |
| string | $module | The module name - e.g. forum, journal, resource, course, user etc |
| string | $action | 'view', 'update', 'add' or 'delete', possibly followed by another word to clarify. |
| string | $url | The file and parameters used to see the results of the action |
| string | $info | Additional description information |
| string | $cm | The course_module->id if there is one |
| string | $user | If log regards $user other than $USER |
Definition at line 1667 of file datalib.php.


| count_login_failures | ( | $ | mode, |
| $ | username, | ||
| $ | lastlogin | ||
| ) |
Returns an object with counts of failed login attempts
Returns information about failed login attempts. If the current user is an admin, then two numbers are returned: the number of attempts and the number of accounts. For non-admins, only the attempts on the given user are shown.
object CONTEXT_SYSTEM
| string | $mode | Either 'admin' or 'everybody' |
| string | $username | The username we are searching for |
| string | $lastlogin | The date from which we are searching |
Definition at line 1935 of file datalib.php.


| coursemodule_visible_for_user | ( | $ | cm, |
| $ | userid = 0 |
||
| ) |
Determine whether a course module is visible within a course, this is different from instance_is_visible() - faster and visibility for user
object object DEBUG_DEVELOPER CONTEXT_MODULE CONDITION_MISSING_EXTRATABLE
| object | $cm | object |
| int | $userid | empty means current user |
Definition at line 1614 of file datalib.php.


Fixes course category and course sortorder, also verifies category and course parents and paths. (circular references are not fixed)
object object MAX_COURSES_IN_CATEGORY MAX_COURSE_CATEGORIES SITEID CONTEXT_COURSE
Definition at line 975 of file datalib.php.


| get_admins | ( | ) |
Returns list of all admins, using 1 DB query
Definition at line 89 of file datalib.php.

| 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.
Returns an array of all the active instances of a particular module in a given course, sorted in the order they are defined in the course. Returns an empty array on any errors.
The returned objects includle the columns cw.section, cm.visible, cm.groupmode and cm.groupingid, cm.groupmembersonly, and are indexed by cm.id.
Simply calls all_instances_in_courses() with a single provided course
| string | $modulename | The name of the module to get instances for |
| object | $course | The course obect. |
| int | $userid | |
| int | $includeinvisible |
Definition at line 1563 of file datalib.php.


| 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
Returns an array of all the active instances of a particular module in given courses, sorted in the order they are defined in the course. Returns an empty array on any errors.
The returned objects includle the columns cw.section, cm.visible, cm.groupmode and cm.groupingid, cm.groupmembersonly, and are indexed by cm.id.
object object
| string | $modulename | The name of the module to get instances for |
| array | $courses | an array of course objects. |
| int | $userid | |
| int | $includeinvisible |
Definition at line 1494 of file datalib.php.


| get_all_subcategories | ( | $ | catid | ) |
Returns an array of category ids of all the subcategories for a given category.
object
| int | $catid | - The id of the category whose subcategories we want to find. |
Definition at line 907 of file datalib.php.
| get_categories | ( | $ | parent = 'none', |
| $ | sort = NULL, |
||
| $ | shallow = true |
||
| ) |
Returns a sorted list of categories. Each category object has a context property that is a context object.
When asking for $parent='none' it will return all the categories, regardless of depth. Wheen asking for a specific parent, the default is to return a "shallow" resultset. Pass false to $shallow and it will return all the child categories as well.
object CONTEXT_COURSECAT
| string | $parent | The parent category if any |
| string | $sort | the sortorder |
| bool | $shallow | - set to false to get the children too |
Definition at line 846 of file datalib.php.


| get_course_category | ( | $ | catid = 0 | ) |
Return specified category, default if given does not exist
object MAX_COURSES_IN_CATEGORY CONTEXT_COURSECAT SYSCONTEXTID
| int | $catid | course category id |
Definition at line 931 of file datalib.php.


| get_course_mods | ( | $ | courseid | ) |
MODULE FUNCTIONS /////////////////////////////////////////////////.
Just gets a raw list of all modules in a course
object
| int | $courseid | The id of the course as found in the 'course' table. |
Definition at line 1337 of file datalib.php.

| 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
| string | $modulename | name of module type, eg. resource, assignment,... (optional, slower and less safe if not specified) |
| int | $cmid | course module id (id in course_modules table) |
| int | $courseid | optional course id for extra validation |
| bool | $sectionnum | include relative section number (0,1,2 ...) |
| int | $strictness | IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found; IGNORE_MULTIPLE means return first, ignore multiple records found(not recommended); MUST_EXIST means throw exception if no record or multiple records found |
Definition at line 1364 of file datalib.php.

| get_coursemodule_from_instance | ( | $ | modulename, |
| $ | instance, | ||
| $ | courseid = 0, |
||
| $ | sectionnum = false, |
||
| $ | strictness = IGNORE_MISSING |
||
| ) |
Given an instance number of a module, finds the coursemodule description
object
| string | $modulename | name of module type, eg. resource, assignment,... |
| int | $instance | module instance number (id in resource, assignment etc. table) |
| int | $courseid | optional course id for extra validation |
| bool | $sectionnum | include relative section number (0,1,2 ...) |
| int | $strictness | IGNORE_MISSING means compatible mode, false returned if record not found, debug message if more found; IGNORE_MULTIPLE means return first, ignore multiple records found(not recommended); MUST_EXIST means throw exception if no record or multiple records found |
Definition at line 1418 of file datalib.php.
| get_coursemodules_in_course | ( | $ | modulename, |
| $ | courseid, | ||
| $ | extrafields = '' |
||
| ) |
Returns all course modules of given activity in course
| string | $modulename | The module name (forum, quiz, etc.) |
| int | $courseid | The course id to get modules for |
| string | $extrafields | extra fields starting with m. |
Definition at line 1456 of file datalib.php.
| get_courses | ( | $ | categoryid = "all", |
| $ | sort = "c.sortorder ASC", |
||
| $ | fields = "c.*" |
||
| ) |
Returns list of courses, for whole site, or category
Returns list of courses, for whole site, or category Important: Using c.* for fields is extremely expensive because we are using distinct. You almost _NEVER_ need all the fields in such a large SELECT
object object object CONTEXT_COURSE
| string | int | $categoryid | Either a category id or 'all' for everything |
| string | $sort | A field and direction to sort by |
| string | $fields | The additional fields to return |
Definition at line 380 of file datalib.php.


| get_courses_page | ( | $ | categoryid = "all", |
| $ | sort = "c.sortorder ASC", |
||
| $ | fields = "c.*", |
||
| &$ | totalcount, | ||
| $ | limitfrom = "", |
||
| $ | limitnum = "" |
||
| ) |
Returns list of courses, for whole site, or category
Similar to get_courses, but allows paging Important: Using c.* for fields is extremely expensive because we are using distinct. You almost _NEVER_ need all the fields in such a large SELECT
object object object CONTEXT_COURSE
| string | int | $categoryid | Either a category id or 'all' for everything |
| string | $sort | A field and direction to sort by |
| string | $fields | The additional fields to return |
| int | $totalcount | Reference for the number of courses |
| string | $limitfrom | The course to start from |
| string | $limitnum | The number of courses to limit to |
Definition at line 449 of file datalib.php.

| get_courses_search | ( | $ | searchterms, |
| $ | sort = 'fullname ASC', |
||
| $ | page = 0, |
||
| $ | recordsperpage = 50, |
||
| &$ | totalcount | ||
| ) |
A list of courses that match a search
object object
| array | $searchterms | An array of search criteria |
| string | $sort | A field and direction to sort by |
| int | $page | The page number to get |
| int | $recordsperpage | The number of records per page |
| int | $totalcount | Passed in by reference. |
Initially we aren't going to perform NOT LIKE searches, only MSSQL and Oracle
will use it to simulate the "-" operator with LIKE clause
Under Oracle and MSSQL, trim the + and - operators and perform simpler LIKE (or NOT LIKE) queries
Definition at line 732 of file datalib.php.

| get_courses_wmanagers | ( | $ | categoryid = 0, |
| $ | sort = "c.sortorder ASC", |
||
| $ | fields = array() |
||
| ) |
Retrieve course records with the course managers and other related records that we need for print_course(). This allows print_courses() to do its job in a constant number of DB queries, regardless of the number of courses, role assignments, etc.
The returned array is indexed on c.id, and each course will have
object object object CONTEXT_COURSE CONTEXT_SYSTEM CONTEXT_COURSECAT SITEID
| int | string | $categoryid | Either the categoryid for the courses or 'all' |
| string | $sort | A SQL sort field and direction |
| array | $fields | An array of additional fields to fetch |
Definition at line 523 of file datalib.php.


| get_logs | ( | $ | select, |
| array $ | params = null, |
||
| $ | order = 'l.time DESC', |
||
| $ | limitfrom = '', |
||
| $ | limitnum = '', |
||
| &$ | totalcount | ||
| ) |
Select all log records based on SQL criteria
object
| string | $select | SQL select criteria |
| array | $params | named sql type params |
| string | $order | SQL order by clause to sort the records returned |
| string | $limitfrom | ? |
| int | $limitnum | ? |
| int | $totalcount | Passed in by reference. |
Definition at line 1830 of file datalib.php.

| get_logs_usercourse | ( | $ | userid, |
| $ | courseid, | ||
| $ | coursestart | ||
| ) |
Select all log records for a given course and user
object DAYSECS
| int | $userid | The id of the user as found in the 'user' table. |
| int | $courseid | The id of the course as found in the 'course' table. |
| string | $coursestart | ? |
Definition at line 1871 of file datalib.php.
| get_logs_userday | ( | $ | userid, |
| $ | courseid, | ||
| $ | daystart | ||
| ) |
Select all log records for a given course, user, and day
object HOURSECS
| int | $userid | The id of the user as found in the 'user' table. |
| int | $courseid | The id of the course as found in the 'course' table. |
| string | $daystart | ? |
Definition at line 1901 of file datalib.php.
| get_my_remotecourses | ( | $ | userid = 0 | ) |
List of remote courses that a user has access to via MNET. Works only on the IDP
object object
| int | The user id to get remote courses for |
Definition at line 1207 of file datalib.php.

List of remote hosts that a user has access to via MNET. Works on the SP
object object
Definition at line 1236 of file datalib.php.

| get_scales_menu | ( | $ | courseid = 0 | ) |
Returns a menu of all available scales from the site as well as the given course
object
| int | $courseid | The id of the course as found in the 'course' table. |
Definition at line 1285 of file datalib.php.


| get_site | ( | ) |
OTHER SITE AND COURSE FUNCTIONS /////////////////////////////////////////////.
Returns $course object of the top-level site.
Definition at line 347 of file datalib.php.

| 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 DEBUG_DEVELOPER SQL_PARAMS_NAMED
| bool | $get | If false then only a count of the records is returned |
| string | $search | A simple string to search for |
| bool | $confirmed | A switch to allow/disallow unconfirmed users |
| array | $exceptions | A list of IDs to ignore, eg 2,4,5,8,9,10 |
| string | $sort | A SQL snippet for the sorting criteria to use |
| string | $firstinitial | Users whose first name starts with $firstinitial |
| string | $lastinitial | Users whose last name starts with $lastinitial |
| string | $page | The page or records to return |
| string | $recordsperpage | The number of records to return per page |
| string | $fields | A comma separated list of fields to be returned from the chosen table. |
Definition at line 196 of file datalib.php.

Full list of users that have confirmed their accounts.
object
Definition at line 331 of file datalib.php.
| get_users_listing | ( | $ | sort = 'lastaccess', |
| $ | dir = 'ASC', |
||
| $ | page = 0, |
||
| $ | recordsperpage = 0, |
||
| $ | search = '', |
||
| $ | firstinitial = '', |
||
| $ | lastinitial = '', |
||
| $ | extraselect = '', |
||
| array $ | extraparams = null, |
||
| $ | extracontext = null |
||
| ) |
| string | $sort | An SQL field to sort by |
| string | $dir | The sort direction ASC|DESC |
| int | $page | The page or records to return |
| int | $recordsperpage | The number of records to return per page |
| string | $search | A simple string to search for |
| string | $firstinitial | Users whose first name starts with $firstinitial |
| string | $lastinitial | Users whose last name starts with $lastinitial |
| string | $extraselect | An additional SQL select statement to append to the query |
| array | $extraparams | Additional parameters to use for the above $extraselect |
| object | $extracontext | If specified, will include user 'extra fields' as appropriate for current user and given context |
Definition at line 268 of file datalib.php.

| instance_is_visible | ( | $ | moduletype, |
| $ | module | ||
| ) |
Determine whether a module instance is visible within a course
Given a valid module object with info about the id and course, and the module's type (eg "forum") returns whether the object is visible or not, groupmembersonly visibility not tested
object
| $moduletype | Name of the module eg 'forum' |
| $module | Object which is the instance of the module |
Definition at line 1581 of file datalib.php.

This function creates a default separated/connected scale
This function creates a default separated/connected scale so there's something in the database. The locations of strings and files is a bit odd, but this is because we need to maintain backward compatibility with many different existing language translations and older sites.
object
Definition at line 1260 of file datalib.php.

| print_object | ( | $ | object | ) |
GENERAL HELPFUL THINGS ///////////////////////////////////.
Dumps a given object's information for debugging purposes
When used in a CLI script, the object's information is written to the standard error output stream. When used in a web script, the object is dumped to a pre-formatted block with the "notifytiny" CSS class.
| mixed | $object | The data to be printed |
Definition at line 1969 of file datalib.php.


| search_users | ( | $ | courseid, |
| $ | groupid, | ||
| $ | searchtext, | ||
| $ | sort = '', |
||
| array $ | exceptions = null |
||
| ) |
Search through course users
If $coursid specifies the site course then this function searches through all undeleted and confirmed users
object SITEID SQL_PARAMS_NAMED CONTEXT_COURSE
| int | $courseid | The course in question. |
| int | $groupid | The group in question. |
| string | $searchtext | The string to search for |
| string | $sort | A field to sort by |
| array | $exceptions | A list of IDs to ignore, eg 2,4,5,8,9,10 |
Definition at line 120 of file datalib.php.

| update_timezone_records | ( | $ | timezones | ) |
Given a set of timezone records, put them in the database, replacing what is there
object
| array | $timezones | An array of timezone records |
Clear out all the old stuff
Insert all the new stuff
Definition at line 1312 of file datalib.php.
| user_accesstime_log | ( | $ | courseid = 0 | ) |
Store user last access times - called when use enters a course or site
object object object LASTACCESS_UPDATE_SECS SITEID
| int | $courseid,empty | means site |
Store site lastaccess time for the current user
Update $USER->lastaccess for next checks
no user_lastaccess for frontpage
Store course lastaccess times for the current user
Definition at line 1757 of file datalib.php.


object CONTEXT_COURSECAT
Definition at line 2003 of file datalib.php.

| xmldb_debug | ( | $ | message, |
| $ | object | ||
| ) |
This function is the official hook inside XMLDB stuff to delegate its debug to one external function.
Any script can avoid calls to this function by defining XMLDB_SKIP_DEBUG_HOOK before using XMLDB classes. Obviously, also, if this function doesn't exist, it isn't invoked ;-)
DEBUG_DEVELOPER
| string | $message | string contains the error message |
| object | $object | object XMLDB object that fired the debug |
Definition at line 1993 of file datalib.php.
