<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

namespace local_kid\event;

defined('MOODLE_INTERNAL') || die();

/**
 * Fired only when staff (local/kid:viewany) previews another student's
 * FULL record (`pages/student.php?studentid=`, `$ispreview === true`) —
 * never for a student's own routine consultation of their own published
 * record, which stays untraced (high-volume, self-access, no audit value).
 * This is the plan's most RGPD-sensitive read: access to unpublished,
 * nominative data.
 */
class dossier_consulted extends \core\event\base {

    protected function init() {
        $this->data['crud'] = 'r';
        $this->data['edulevel'] = self::LEVEL_OTHER;
    }

    public static function get_name() {
        return get_string('event_dossier_consulted', 'local_kid');
    }

    public function get_description() {
        $studentid = $this->other['studentid'] ?? 0;
        return "The user with id '{$this->userid}' previewed the full record of student '$studentid'.";
    }

    public function get_url() {
        return new \moodle_url('/local/kid/pages/student.php');
    }
}
