From 2d56dc168ebe5cadbbef53b3b8853d87bc2cfbba Mon Sep 17 00:00:00 2001
From: alex <alex@alexloehr.net>
Date: Wed, 18 Jun 2025 18:25:48 +0000
Subject: [PATCH] GS-2166

---
 php/globus-ilias-rest/api.php   |   12 +++++++++++-
 README.md                       |   10 ++++++++++
 php/globus-ilias-rest/README.md |   13 +++++++++++++
 3 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/README.md b/README.md
index 65a9d8c..4a7676a 100644
--- a/README.md
+++ b/README.md
@@ -30,6 +30,16 @@
     pm2 save
 
 
+### PHP Komponente
+
+globus-ilias-rest benötigt eine PHP Komponente um die ILIAS internen Funktionen nutzen zu können.
+Dazu den Ordner "php/globus-ilias-rest" im Projektverzeichnis symlinken in den ILIAS Basisordner (wo sich auch ilias.php befindet).
+
+    cd $ILIASBASEDIR
+    ln -s $RESTPROJ/php/globus-ilias-rest globus-ilias-rest
+
+
+
 ### Apache Config
 
 Apache muss als Proxy für globus-ilias-rest fungieren und Verbindungen an diesen weiterreichen.
diff --git a/php/globus-ilias-rest/README.md b/php/globus-ilias-rest/README.md
new file mode 100644
index 0000000..05f03ac
--- /dev/null
+++ b/php/globus-ilias-rest/README.md
@@ -0,0 +1,13 @@
+# Warning
+
+This file should not be called directly. This is for internal use of globus-ilias-rest API.
+It is used by the node component (main component) of globus-ilias-rest.
+
+# Install
+
+Copy or symlink this folder into the ILIAS-Base-Folder (where ilias.php is located).
+
+## Auth
+
+All Requests to api.php require a valid token (as defined in the file "token").
+
diff --git a/php/globus-ilias-rest/api.php b/php/globus-ilias-rest/api.php
index b56c520..b340e2c 100644
--- a/php/globus-ilias-rest/api.php
+++ b/php/globus-ilias-rest/api.php
@@ -6,6 +6,7 @@
 
 try {
     # Init ILIAS
+    chdir("..");
     require_once("Services/Init/classes/class.ilInitialisation.php");
     ilInitialisation::initILIAS();
 
@@ -39,8 +40,16 @@
         die(); // this ends here
     }
 
+
+
     try {
         switch ($command) {
+            case "ping":
+                if($method == "GET") {
+                    $res["msg"] = "pong";
+                    $res["status"] = "ok";
+                    break;
+                }
             case "deleteUser":
                 if ($method == "DELETE") {
                     $res["msg"] = deleteUser($obj_id, $dry);
@@ -57,7 +66,8 @@
                 }
             default:
                 http_response_code(500);
-                $res = array("status" => "error", "msg" => "unknown command or method");
+                $res["status"] = "error";
+                $res["msg"] = "unknown command or method";
         }
     } catch (Exception $err) {
         http_response_code(500);

--
Gitblit v1.8.0