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

Public Member Functions

 __construct ($properties)
 Loads the properties for this course request object.
 
 __get ($key)
 Returns the requested property.
 
 __isset ($key)
 Override this to ensure empty($request->blah) calls return a reliable answer...
 
 approve ()
 This function approves the request turning it into a course.
 
 can_approve ()
 Checks user capability to approve a requested course.
 
 check_shortname_collision ($shortnamemark='[*]')
 Checks that the shortname used by the course does not conflict with any other courses that exist.
 
 delete ()
 Deletes the course request and any associated files.
 
 get_category ()
 Returns the category where this course request should be created.
 
 get_requester ()
 Returns the user who requested this course.
 
 reject ($notice)
 Reject a course request.
 

Static Public Member Functions

static can_request (context $context)
 Checks if current user can request a course in this context.
 
static create ($data)
 Static function to create a new course request when passed an array of properties for it.
 
static prepare ($data=null)
 Static function to prepare the summary editor for working with a course request.
 
static summary_editor_options ()
 Returns an array of options to use with a summary editor.
 

Protected Member Functions

 notify ($touser, $fromuser, $name, $subject, $message, $courseid=null)
 Send a message from one user to another using events_trigger.
 

Protected Attributes

stdClass $properties
 This is the stdClass that stores the properties for the course request and is externally accessed through the __get magic method.
 

Static Protected Attributes

static array $summaryeditoroptions
 An array of options for the summary editor used by course request forms.
 

Constructor & Destructor Documentation

◆ __construct()

course_request::__construct ( $properties)

Loads the properties for this course request object.

Id is required and if only id is provided then we load the rest of the properties from the database

Parameters
stdClass | int$propertiesEither an object containing properties or the course_request id to load

Member Function Documentation

◆ __get()

course_request::__get ( $key)

Returns the requested property.

Parameters
string$key
Return values
mixed

◆ __isset()

course_request::__isset ( $key)

Override this to ensure empty($request->blah) calls return a reliable answer...

This is required because we define the __get method

Parameters
mixed$key
Return values
boolTrue is it not empty, false otherwise

◆ approve()

course_request::approve ( )

This function approves the request turning it into a course.

This function converts the course request into a course, at the same time transferring any files used in the summary to the new course and then removing the course request and the files associated with it.

Return values
intThe id of the course that was created from this request

◆ can_approve()

course_request::can_approve ( )

Checks user capability to approve a requested course.

If course was requested without category for some reason (might happen if $CFG->defaultrequestcategory is misconfigured), we check capabilities 'moodle/site:approvecourse' and 'moodle/course:changecategory'.

Return values
bool

◆ can_request()

static course_request::can_request ( context $context)
static

Checks if current user can request a course in this context.

Parameters
context$context
Return values
bool

◆ check_shortname_collision()

course_request::check_shortname_collision ( $shortnamemark = '[*]')

Checks that the shortname used by the course does not conflict with any other courses that exist.

Parameters
string | null$shortnamemarkThe string to append to the requests shortname should a conflict be found
Return values
booltrue is there is a conflict, false otherwise

◆ create()

static course_request::create ( $data)
static

Static function to create a new course request when passed an array of properties for it.

This function also handles saving any files that may have been used in the editor

Parameters
stdClass$data
Return values
course_requestThe newly created course request

◆ get_category()

course_request::get_category ( )

Returns the category where this course request should be created.

Note that we don't check here that user has a capability to view hidden categories if he has capabilities 'moodle/site:approvecourse' and 'moodle/course:changecategory'

Return values
core_course_category

◆ get_requester()

course_request::get_requester ( )

Returns the user who requested this course.

Uses a static var to cache the results and cut down the number of db queries

@staticvar array $requesters An array of cached users

Return values
stdClassThe user who requested the course

◆ notify()

course_request::notify ( $touser,
$fromuser,
$name,
$subject,
$message,
$courseid = null )
protected

Send a message from one user to another using events_trigger.

Parameters
object$touser
object$fromuser
string$name
string$subject
string$message
int | null$courseid

◆ prepare()

static course_request::prepare ( $data = null)
static

Static function to prepare the summary editor for working with a course request.

Parameters
null | stdClass$dataOptional, an object containing the default values for the form, these may be modified when preparing the editor so this should be called before creating the form
Return values
stdClassAn object that can be used to set the default values for an mforms form

◆ reject()

course_request::reject ( $notice)

Reject a course request.

This function rejects a course request, emailing the requesting user the provided notice and then removing the request from the database

Parameters
string$noticeThe message to display to the user

◆ summary_editor_options()

static course_request::summary_editor_options ( )
static

Returns an array of options to use with a summary editor.

@uses course_request\$summaryeditoroptions

Return values
arrayAn array of options to use with the editor

Member Data Documentation

◆ $summaryeditoroptions

array course_request::$summaryeditoroptions
staticprotected

An array of options for the summary editor used by course request forms.

This is initially set by summary_editor_options()


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