moodle-tool_sptoolboxmgr/lib.php

46 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2024-03-22 22:10:56 +01:00
<?php
// This file is part of the Studyplan plugin for Moodle
//
// 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.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
/**
* Library page
* @package tool_sptoolboxmgr
* @copyright 2023 P.M. Kuipers
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
2024-05-12 23:34:48 +02:00
use \local_treestudyplan\studyplan;
use \local_treestudyplan\associationservice;
/**
* Hook to handle when a user is deleted
* @param stdClass $user The user object that will be deleted
*/
function tool_sptoolboxmgr_pre_user_delete($user) {
$userplans = studyplan::find_for_user($user->id);
foreach ($userplans as $uplan) {
$uids = $uplan->find_linked_userids();
$directuids = $uplan->get_linked_user_ids();
if (count($uids) == 1 && $uids[0] == $user->id) {
if(true) {
}
} else {
associationservice::disconnect_user($uplan->id(),$user->id);
}
}
}