Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
core_course_list_element Class Reference
Inheritance diagram for core_course_list_element:

Public Member Functions

 __construct (stdClass $record)
 Creates an instance of the class from record.
 
 __get ($name)
 Magic method to get a course property.
 
 __isset ($name)
 Magic method to check if property is set.
 
 __set ($name, $value)
 Magic setter method, we do not want anybody to modify properties from the outside.
 
 __unset ($name)
 All properties are read only, sorry.
 
 can_access ()
 Returns true if the current user can access this course.
 
 can_backup ()
 Returns true if the current user can backup this course.
 
 can_change_visibility ()
 Returns true if the user can change the visibility of this course.
 
 can_delete ()
 Returns true if the current user can delete this course.
 
 can_edit ()
 Returns true if the user can edit this courses settings.
 
 can_restore ()
 Returns true if the current user can restore this course.
 
 can_review_enrolments ()
 Returns true if the current user can review enrolments for this course.
 
 get_context ()
 Returns the context for this course.
 
 get_course_contacts ()
 Returns list of course contacts (usually teachers) to display in course link.
 
 get_course_overviewfiles ()
 Returns all course overview files.
 
 get_custom_fields ()
 Returns custom fields data for this course.
 
 get_formatted_fullname ()
 Returns the formatted fullname for this course.
 
 get_formatted_name ()
 Returns the name of this course as it should be displayed within a list.
 
 get_formatted_shortname ()
 Returns the formatted shortname for this course.
 
 getIterator ()
 Create an iterator because magic vars can't be seen by 'foreach'.
 
 has_course_contacts ()
 Indicates if the course have course contacts to display.
 
 has_course_overviewfiles ()
 Checks if course has any associated overview files.
 
 has_custom_fields ()
 Does this course have custom fields.
 
 has_summary ()
 Indicates if the course has non-empty summary field.
 

Protected Attributes

bool $canaccess = null
 true if the current user can access the course, false otherwise.
 
array $coursecontacts
 array of course contacts - stores result of call to get_course_contacts()
 
stdClass $record
 record retrieved from DB, may have additional calculated property such as managers and hassummary
 

Constructor & Destructor Documentation

◆ __construct()

core_course_list_element::__construct ( stdClass $record)

Creates an instance of the class from record.

Parameters
stdClass$recordexcept fields from course table it may contain field hassummary indicating that summary field is not empty. Also it is recommended to have context fields here ready for context preloading

Member Function Documentation

◆ __get()

core_course_list_element::__get ( $name)

Magic method to get a course property.

Returns any field from table course (retrieves it from DB if it was not retrieved before)

Parameters
string$name
Return values
mixed

◆ __isset()

core_course_list_element::__isset ( $name)

Magic method to check if property is set.

Parameters
string$name
Return values
bool

◆ __set()

core_course_list_element::__set ( $name,
$value )

Magic setter method, we do not want anybody to modify properties from the outside.

Parameters
string$name
mixed$value

◆ __unset()

core_course_list_element::__unset ( $name)

All properties are read only, sorry.

Parameters
string$name

◆ can_access()

core_course_list_element::can_access ( )

Returns true if the current user can access this course.

Return values
bool

◆ can_backup()

core_course_list_element::can_backup ( )

Returns true if the current user can backup this course.

Note: this function does not check that the current user can access the course. To do that please call require_login with the course, or if not possible call core_course_list_element::can_access()

Return values
bool

◆ can_change_visibility()

core_course_list_element::can_change_visibility ( )

Returns true if the user can change the visibility of this course.

Note: this function does not check that the current user can access the course. To do that please call require_login with the course, or if not possible call core_course_list_element::can_access()

Return values
bool

◆ can_delete()

core_course_list_element::can_delete ( )

Returns true if the current user can delete this course.

Note: this function does not check that the current user can access the course. To do that please call require_login with the course, or if not possible call core_course_list_element::can_access()

Return values
bool

◆ can_edit()

core_course_list_element::can_edit ( )

Returns true if the user can edit this courses settings.

Note: this function does not check that the current user can access the course. To do that please call require_login with the course, or if not possible call core_course_list_element::can_access()

Return values
bool

◆ can_restore()

core_course_list_element::can_restore ( )

Returns true if the current user can restore this course.

Note: this function does not check that the current user can access the course. To do that please call require_login with the course, or if not possible call core_course_list_element::can_access()

Return values
bool

◆ can_review_enrolments()

core_course_list_element::can_review_enrolments ( )

Returns true if the current user can review enrolments for this course.

Note: this function does not check that the current user can access the course. To do that please call require_login with the course, or if not possible call core_course_list_element::can_access()

Return values
bool

◆ get_context()

core_course_list_element::get_context ( )

Returns the context for this course.

Return values
context_course

◆ get_course_contacts()

core_course_list_element::get_course_contacts ( )

Returns list of course contacts (usually teachers) to display in course link.

Roles to display are set up in $CFG->coursecontact

The result is the list of users where user id is the key and the value is an array with elements:

  • 'user' - object containing basic user information
  • 'role' - object containing basic role information (id, name, shortname, coursealias)
  • 'rolename' => role_get_name($role, $context, ROLENAME_ALIAS)
  • 'username' => fullname($user, $canviewfullnames)
Return values
array

◆ get_course_overviewfiles()

core_course_list_element::get_course_overviewfiles ( )

Returns all course overview files.

Return values
arrayarray of stored_file objects

◆ get_custom_fields()

core_course_list_element::get_custom_fields ( )

Returns custom fields data for this course.

Return values
core_customfield\data_controller[]

◆ get_formatted_fullname()

core_course_list_element::get_formatted_fullname ( )

Returns the formatted fullname for this course.

Return values
string

◆ get_formatted_name()

core_course_list_element::get_formatted_name ( )

Returns the name of this course as it should be displayed within a list.

Return values
string

◆ get_formatted_shortname()

core_course_list_element::get_formatted_shortname ( )

Returns the formatted shortname for this course.

Return values
string

◆ getIterator()

core_course_list_element::getIterator ( )

Create an iterator because magic vars can't be seen by 'foreach'.

Exclude context fields

Implementing method from interface IteratorAggregate

Return values
ArrayIterator

◆ has_course_contacts()

core_course_list_element::has_course_contacts ( )

Indicates if the course have course contacts to display.

Return values
bool

◆ has_course_overviewfiles()

core_course_list_element::has_course_overviewfiles ( )

Checks if course has any associated overview files.

Return values
bool

◆ has_custom_fields()

core_course_list_element::has_custom_fields ( )

Does this course have custom fields.

Return values
bool

◆ has_summary()

core_course_list_element::has_summary ( )

Indicates if the course has non-empty summary field.

Return values
bool

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