Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
/lib/ -> licenselib.php (source)

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

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: 407 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

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

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.

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

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

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

enable($license)   X-Ref
Enable a license

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

disable($license)   X-Ref
Disable a license

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

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.