Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 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.
/lib/ -> licenselib.php (source)

Differences Between: [Versions 39 and 310] [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 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: 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.