Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
license_manager Class Reference

Public Member Functions

 add ()
 

Static Public Member Functions

static change_license_sortorder (int $direction, string $licenseshortname)
 Change the sort order of a license (and it's sibling license as a result).
 
static delete ($licenseshortname)
 Delete a custom license.
 
static disable ($license)
 Disable a license.
 
static enable ($license)
 Enable a license.
 
static get_active_licenses ()
 Get the globally configured active licenses.
 
static get_active_licenses_as_array ()
 Get the globally configured active licenses as an array.
 
static get_license_by_shortname (string $name)
 Get license record by shortname.
 
static get_licenses ()
 Get license records.
 
static install_licenses ()
 Install moodle built-in licenses.
 
static read (array $params=[])
 Read licens record(s) from database.
 
static reset_license_cache ()
 Reset the license cache so it rebuilds next time licenses are fetched.
 
static save ($license)
 Save a license record.
 

Public Attributes

const CORE_LICENSE = 0
 License is a core license and can not be updated or deleted.
 
const CUSTOM_LICENSE = 1
 License is a custom license and can be updated and/or deleted.
 
const LICENSE_DISABLED = 0
 Integer representation of boolean for a license that is disabled.
 
const LICENSE_ENABLED = 1
 Integer representation of boolean for a license that is enabled.
 
const LICENSE_MOVE_DOWN = 1
 Integer for moving a license down order.
 
const LICENSE_MOVE_UP = -1
 Integer for moving a license up order.
 

Static Protected Member Functions

static create ($license)
 Create a license record.
 
static set_active_licenses ()
 Store active licenses in global config.
 
static update ($license)
 Update a license record.
 

Member Function Documentation

◆ add()

license_manager::add ( )

◆ change_license_sortorder()

static license_manager::change_license_sortorder ( int $direction,
string $licenseshortname )
static

Change the sort order of a license (and it's sibling license as a result).

Parameters
int$directionvalue to change sortorder of license by.
string$licenseshortnamethe shortname of license to changes sortorder for.
Exceptions
moodle_exceptionif attempting to use invalid direction value.

◆ create()

static license_manager::create ( $license)
staticprotected

Create a license record.

Parameters
object$licensethe license to create record for.

◆ delete()

static license_manager::delete ( $licenseshortname)
static

Delete a custom license.

Parameters
string$licenseshortnamethe shortname of license.
Exceptions
moodle_exceptionwhen attempting to delete a license you are not allowed to.

◆ disable()

static license_manager::disable ( $license)
static

Disable a license.

Parameters
string$licensethe shortname of license
Return values
boolean

◆ enable()

static license_manager::enable ( $license)
static

Enable a license.

Parameters
string$licensethe shortname of license
Return values
boolean

◆ get_active_licenses()

static license_manager::get_active_licenses ( )
static

Get the globally configured active licenses.

Return values
arrayof license objects.
Exceptions
coding_exception

◆ get_active_licenses_as_array()

static license_manager::get_active_licenses_as_array ( )
static

Get the globally configured active licenses as an array.

Return values
array\$licensesan associative array of licenses shaped as ['shortname' => 'fullname']

◆ get_license_by_shortname()

static license_manager::get_license_by_shortname ( string $name)
static

Get license record by shortname.

Parameters
string$namethe shortname of license
Return values
object|nullthe license or null if no license found.

◆ get_licenses()

static license_manager::get_licenses ( )
static

Get license records.

Return values
array|falseobject[] of license records of false if none.

◆ read()

static license_manager::read ( array $params = [])
static

Read licens record(s) from database.

Parameters
array$paramslicense parameters to return licenses for.
Return values
array\$filteredlicensesobject[] of licenses.

◆ save()

static license_manager::save ( $license)
static

Save a license record.

Parameters
object$license{ shortname => string a shortname of license, will be refered by files table[required] fullname => string the fullname of the license [required] source => string the homepage of the license type[required] enabled => int is it enabled? version => int a version number used by moodle [required] }

◆ update()

static license_manager::update ( $license)
staticprotected

Update a license record.

Parameters
object$licensethe license to update record for.
Exceptions
moodle_exceptionif attempting to update a core license.

The documentation for this class was generated from the following file: