From a845b328e326fc8c827ca43fafd43e8c39640275 Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Wed, 18 Jun 2025 09:38:52 +0000
Subject: [PATCH] adding iliastoken
---
php/alex.php | 46 ++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/php/alex.php b/php/alex.php
index be5251b..3f6ff54 100644
--- a/php/alex.php
+++ b/php/alex.php
@@ -1,20 +1,24 @@
<?php
declare(strict_types=1);
+$token = "jkhHKhui899HUKHBzGHtgoiedko2393490";
+
try {
# Init ILIAS
require_once("Services/Init/classes/class.ilInitialisation.php");
ilInitialisation::initILIAS();
- include_once 'Services/Context/classes/class.ilContext.php';
- ilContext::init(ilContext::CONTEXT_REST);
+ #include_once 'Services/Context/classes/class.ilContext.php';
+ #ilContext::init(ilContext::CONTEXT_REST);
header("Content-Type: application/json; charset=UTF-8");
$method = $_SERVER['REQUEST_METHOD'];
+ $curtoken = $_GET["token"];
$command = $_GET["command"];
$obj_id = (int) $_GET["obj_id"];
$dry = $_GET["dry"]; # "0" = false, "1" = true
+
$res = array(
"method" => $method,
@@ -24,11 +28,29 @@
"msg" => null
);
+ // check token
+ if($token !== $curtoken) {
+ http_response_code(403);
+ $res["status"] = "error";
+ $res["msg"] = "access denied";
+ $json = json_encode($res, JSON_PRETTY_PRINT);
+ echo $json;
+ die(); // this ends here
+ }
+
try {
switch ($command) {
case "deleteUser":
if ($method == "DELETE") {
$res["msg"] = deleteUser($obj_id, $dry);
+ $res["status"] = "ok";
+ break;
+ }
+ case "deleteTeilnahme":
+ if ($method == "DELETE") {
+ $usr_id = (int) $_GET["usr_id"];
+ $res["usr_id"] = $usr_id;
+ $res["msg"] = deleteTeilnahme($obj_id, $usr_id, $dry);
$res["status"] = "ok";
break;
}
@@ -64,4 +86,24 @@
}
}
+function deleteTeilnahme($obj_id, $usr_id, $dry) {
+ # beim Löschen durch den Kurs wird zwar die Teilnahme gelöscht, aber nicht die Rollenzugehörigkeit
+ $course = ilObjectFactory::getInstanceByObjId($obj_id);
+
+ $parti = ilCourseParticipant::_getInstanceByObjId($obj_id, $usr_id); ## Achtung die usr_id hier ist Admin id??
+ #return "parti.isParticipant() = {$parti->isParticipant()}";
+
+ $msg = "deleted user({$usr_id}) teilnahme for course '{$course->getTitle()}' ({$obj_id})";
+ if ($dry == "0") {
+ #$course->_deleteUser($usr_id);
+ #$course->deleteUser($usr_id); ## undefined
+ $parti->delete($usr_id);
+ return $msg;
+ } else {
+ $msg = "DRY:: ".$msg;
+ return $msg;
+ }
+}
+
?>
+
--
Gitblit v1.8.0