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

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: