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

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

A namespace contains license specific functions

Copyright: 2010 Dongsheng Cai <dongsheng@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 408 lines (13 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

license_manager:: (16 methods):
  save()
  add()
  create()
  read()
  update()
  delete()
  get_licenses()
  change_license_sortorder()
  get_license_by_shortname()
  enable()
  disable()
  set_active_licenses()
  get_active_licenses()
  get_active_licenses_as_array()
  install_licenses()
  reset_license_cache()


Class: license_manager  - X-Ref

save($license)   X-Ref
Save a license record.

param: object $license {

add($license)   X-Ref
Adding a new license type

return: bool true on success.
param: object $license the license record to add.

create($license)   X-Ref
Create a license record.

param: object $license the license to create record for.

read(array $params = [])   X-Ref
Read licens record(s) from database.

return: array $filteredlicenses object[] of licenses.
param: array $params license parameters to return licenses for.

update($license)   X-Ref
Update a license record.

param: object $license the license to update record for.

delete($licenseshortname)   X-Ref
Delete a custom license.

param: string $licenseshortname the shortname of license.

get_licenses()   X-Ref
Get license records.

return: array|false object[] of license records of false if none.

change_license_sortorder(int $direction, string $licenseshortname)   X-Ref
Change the sort order of a license (and it's sibling license as a result).

param: int $direction value to change sortorder of license by.
param: string $licenseshortname the shortname of license to changes sortorder for.

get_license_by_shortname(string $name)   X-Ref
Get license record by shortname

return: object|null the license or null if no license found.
param: string $name the shortname of license

enable($license)   X-Ref
Enable a license

return: boolean
param: string $license the shortname of license

disable($license)   X-Ref
Disable a license

return: boolean
param: string $license the shortname of license

set_active_licenses()   X-Ref
Store active licenses in global config.


get_active_licenses()   X-Ref
Get the globally configured active licenses.

return: array of license objects.

get_active_licenses_as_array()   X-Ref
Get the globally configured active licenses as an array.

return: array $licenses an associative array of licenses shaped as ['shortname' => 'fullname']

install_licenses()   X-Ref
Install moodle built-in licenses.


reset_license_cache()   X-Ref
Reset the license cache so it rebuilds next time licenses are fetched.