mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-49499 user: Move events triggering to new API function
New function in profile/lib: profile_viewed()
This commit is contained in:
parent
1d3fd63f97
commit
d1b238381f
@ -225,13 +225,7 @@ if ($currentpage->userid == 0) {
|
||||
}
|
||||
|
||||
// Trigger a user profile viewed event.
|
||||
$event = \core\event\user_profile_viewed::create(array(
|
||||
'objectid' => $user->id,
|
||||
'relateduserid' => $user->id,
|
||||
'context' => $usercontext
|
||||
));
|
||||
$event->add_record_snapshot('user', $user);
|
||||
$event->trigger();
|
||||
profile_view($user, $usercontext);
|
||||
|
||||
// TODO WORK OUT WHERE THE NAV BAR IS!
|
||||
echo $OUTPUT->header();
|
||||
|
@ -621,4 +621,33 @@ function profile_load_custom_fields($user) {
|
||||
$user->profile = (array)profile_user_record($user->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger a user profile viewed event.
|
||||
*
|
||||
* @param stdClass $user user object
|
||||
* @param stdClass $context context object (course or user)
|
||||
* @param stdClass $course course object
|
||||
* @since Moodle 2.9
|
||||
*/
|
||||
function profile_view($user, $context, $course = null) {
|
||||
|
||||
$eventdata = array(
|
||||
'objectid' => $user->id,
|
||||
'relateduserid' => $user->id,
|
||||
'context' => $context
|
||||
);
|
||||
|
||||
if (!empty($course)) {
|
||||
$eventdata['courseid'] = $course->id;
|
||||
$eventdata['other'] = array(
|
||||
'courseid' => $course->id,
|
||||
'courseshortname' => $course->shortname,
|
||||
'coursefullname' => $course->fullname
|
||||
);
|
||||
}
|
||||
|
||||
$event = \core\event\user_profile_viewed::create($eventdata);
|
||||
$event->add_record_snapshot('user', $user);
|
||||
$event->trigger();
|
||||
}
|
||||
|
||||
|
@ -209,19 +209,7 @@ if ($user->deleted) {
|
||||
|
||||
// OK, security out the way, now we are showing the user.
|
||||
// Trigger a user profile viewed event.
|
||||
$event = \core\event\user_profile_viewed::create(array(
|
||||
'objectid' => $user->id,
|
||||
'relateduserid' => $user->id,
|
||||
'courseid' => $course->id,
|
||||
'context' => $coursecontext,
|
||||
'other' => array(
|
||||
'courseid' => $course->id,
|
||||
'courseshortname' => $course->shortname,
|
||||
'coursefullname' => $course->fullname
|
||||
)
|
||||
));
|
||||
$event->add_record_snapshot('user', $user);
|
||||
$event->trigger();
|
||||
profile_view($user, $coursecontext, $course);
|
||||
|
||||
// Get the hidden field list.
|
||||
if (has_capability('moodle/user:viewhiddendetails', $coursecontext)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user