Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
|
Public Member Functions | |
__get ($name) | |
Magic getter for read only access. | |
__isset ($name) | |
Is data property set? | |
__set ($name, $value) | |
Magic setter. | |
add_record_snapshot ($tablename, $record) | |
Add cached data that will be most probably used in event observers. | |
can_view ($user_or_id=null) | |
This method was originally intended for granular access control on the event level, unfortunately the proper implementation would be too expensive in many cases. | |
get_assign () | |
Get assign instance. | |
get_context () | |
Returns event context. | |
get_data () | |
Return standardised event data as array. | |
get_description () | |
Returns description of what happened. | |
get_logextra () | |
Return auxiliary data that was stored in logs. | |
get_record_snapshot ($tablename, $id) | |
Returns cached record or fetches data from database if not cached. | |
get_url () | |
Returns relevant URL. | |
getIterator () | |
Create an iterator because magic vars can't be seen by 'foreach'. | |
is_dispatched () | |
Used from event manager to prevent direct access. | |
is_restored () | |
Was this event restored? | |
is_triggered () | |
Was this event already triggered? | |
set_assign (\assign $assign) | |
Set assign instance for this event. | |
trigger () | |
Trigger event. | |
Static Public Member Functions | |
static | create (array $data=null) |
Create new event. | |
static | create_from_grade (\assign $assign, stdClass $grade) |
Create instance of event. | |
static | get_explanation () |
Get an explanation of what the class does. | |
static | get_name () |
Returns localised general event name. | |
static | get_name_with_info () |
Returns the event name complete with metadata information. | |
static | get_objectid_mapping () |
This is used when restoring course logs where it is required that we map the objectid to it's new value in the new course. | |
static | get_other_mapping () |
This is used when restoring course logs where it is required that we map the information in 'other' to it's new value in the new course. | |
static | get_static_info () |
Get static information about an event. | |
static | is_deprecated () |
Whether this event has been marked as deprecated. | |
static | restore (array $data, array $logextra) |
Restore event from existing historic data. | |
static | restore_legacy ($legacy) |
Create fake event from legacy log data. | |
Public Attributes | |
const | LEVEL_OTHER = 0 |
Other level. | |
const | LEVEL_PARTICIPATING = 2 |
Participating level. | |
const | LEVEL_TEACHING = 1 |
Teaching level. | |
const | NOT_FOUND = -31338 |
The value used when an id can not be found during a restore. | |
const | NOT_MAPPED = -31337 |
The value used when an id can not be mapped during a restore. | |
const | USER_NOTLOGGEDIN = 0 |
User id to use when the user is not logged in. | |
const | USER_OTHER = -1 |
User id to use when actor is not an actual user but system, cli or cron. | |
Protected Member Functions | |
init () | |
Init method. | |
validate_before_trigger () | |
Validate all properties right before triggering the event. | |
validate_data () | |
Custom validation. | |
Static Protected Member Functions | |
static | restore_unknown (array $data, array $logextra) |
Restore unknown event. | |
Protected Attributes | |
assign | $assign |
context | $context |
of this event | |
array | $data |
event data | |
array | $legacylogdata |
Legacy log data. | |
array | $logextra |
the format is standardised by logging API | |
|
inherited |
Magic getter for read only access.
string | $name |
mixed |
|
inherited |
Is data property set?
string | $name |
bool |
|
inherited |
Magic setter.
Note: we must not allow modification of data from outside, after trigger() the data MUST NOT CHANGE!!!
string | $name | |
mixed | $value |
coding_exception |
|
finalinherited |
Add cached data that will be most probably used in event observers.
This is used to improve performance, but it is required for data that was just deleted.
string | $tablename | |
stdClass | $record |
coding_exception | if used after trigger() |
|
inherited |
This method was originally intended for granular access control on the event level, unfortunately the proper implementation would be too expensive in many cases.
int | stdClass | $user_or_id | ID of the user. |
bool | True if the user can view the event, false otherwise. |
Reimplemented in mod_feedback\event\response_deleted, and mod_feedback\event\response_submitted.
|
staticfinalinherited |
Create new event.
The optional data keys as: 1/ objectid - the id of the object specified in class name 2/ context - the context of this event 3/ other - the other data describing the event, can not contain objects 4/ relateduserid - the id of user which is somehow related to this event
array | $data |
core\event\base | returns instance of new event |
coding_exception |
|
static |
Create instance of event.
assign | $assign | |
stdClass | $grade |
feedback_viewed |
|
inherited |
Get assign instance.
NOTE: to be used from observers only.
coding_exception |
assign |
|
inherited |
Returns event context.
context |
|
inherited |
Return standardised event data as array.
array | All elements are scalars except the 'other' field which is array. |
mod_assign\event\feedback_viewed::get_description | ( | ) |
|
staticinherited |
Get an explanation of what the class does.
By default returns the phpdocs from the child event class. Ideally this should be overridden to return a translatable get_string style markdown. e.g. return new lang_string('eventyourspecialevent', 'plugin_type');
string | An explanation of the event formatted in markdown style. |
|
inherited |
Return auxiliary data that was stored in logs.
List of standard properties:
array | the format is standardised by logging API |
|
static |
|
staticinherited |
Returns the event name complete with metadata information.
This includes information about whether the event has been deprecated so should not be used in all situations - for example within reports themselves.
If overriding this function, please ensure that you call the parent version too.
string |
|
static |
This is used when restoring course logs where it is required that we map the objectid to it's new value in the new course.
Does nothing in the base class except display a debugging message warning the user that the event does not contain the required functionality to map this information. For events that do not store an objectid this won't be called, so no debugging message will be displayed.
Example of usage:
return array('db' => 'assign_submissions', 'restore' => 'submission');
If the objectid can not be mapped during restore set the value to core\event\base\NOT_MAPPED, example -
return array('db' => 'some_table', 'restore' => core\event\base\NOT_MAPPED);
Note - it isn't necessary to specify the 'db' and 'restore' values in this case, so you can also use -
return core\event\base\NOT_MAPPED;
The 'db' key refers to the database table and the 'restore' key refers to the name of the restore element the objectid is associated with. In many cases these will be the same.
string | the name of the restore mapping the objectid links to |
Reimplemented from core\event\base.
|
static |
This is used when restoring course logs where it is required that we map the information in 'other' to it's new value in the new course.
Does nothing in the base class except display a debugging message warning the user that the event does not contain the required functionality to map this information. For events that do not store any other information this won't be called, so no debugging message will be displayed.
Example of usage:
$othermapped = array(); $othermapped['discussionid'] = array('db' => 'forum_discussions', 'restore' => 'forum_discussion'); $othermapped['forumid'] = array('db' => 'forum', 'restore' => 'forum'); return $othermapped;
If an id can not be mapped during restore we set it to core\event\base\NOT_MAPPED, example -
$othermapped = array(); $othermapped['someid'] = array('db' => 'some_table', 'restore' => core\event\base\NOT_MAPPED); return $othermapped;
Note - it isn't necessary to specify the 'db' and 'restore' values in this case, so you can also use -
$othermapped = array(); $othermapped['someid'] = core\event\base\NOT_MAPPED; return $othermapped;
The 'db' key refers to the database table and the 'restore' key refers to the name of the restore element the other value is associated with. In many cases these will be the same.
array | an array of other values and their corresponding mapping |
Reimplemented from core\event\base.
|
finalinherited |
Returns cached record or fetches data from database if not cached.
string | $tablename | |
int | $id |
stdClass |
coding_exception | if used after restore() |
|
staticfinalinherited |
Get static information about an event.
This is used in reports and is not for general use.
array | Static information about the event. |
|
inherited |
|
inherited |
Create an iterator because magic vars can't be seen by 'foreach'.
ArrayIterator |
|
protected |
Init method.
Reimplemented from core\event\base.
|
staticinherited |
Whether this event has been marked as deprecated.
Events cannot be deprecated in the normal fashion as they must remain to support historical data. Once they are deprecated, there is no way to trigger the event, so it does not make sense to list it in some parts of the UI (e.g. Event Monitor).
boolean |
Reimplemented in core\event\course_module_instances_list_viewed, and core\event\role_capabilities_updated.
|
finalinherited |
Used from event manager to prevent direct access.
bool |
|
finalinherited |
Was this event restored?
bool |
|
finalinherited |
Was this event already triggered?
bool |
|
staticfinalinherited |
Restore event from existing historic data.
array | $data | |
array | $logextra | the format is standardised by logging API |
bool|core\event\base |
|
staticfinalinherited |
Create fake event from legacy log data.
stdClass | $legacy |
base |
|
staticfinalprotectedinherited |
Restore unknown event.
array | $data | |
array | $logextra |
unknown_logged |
|
inherited |
|
protectedinherited |
Validate all properties right before triggering the event.
This throws coding exceptions for fatal problems and debugging for minor problems.
coding_exception |
Reimplemented in core\event\url_blocked.
|
protected |
|
inherited |
Participating level.
Any event that is performed by a user, and is related (or could be related) to his learning experience.
|
inherited |
Teaching level.
Any event that is performed by someone (typically a teacher) and has a teaching value, anything that is affecting the learning experience/environment of the students.