From e7f1909cda2b80149d02e43bb3bf1b32a794cfed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9=20Noack?= <noack@data-quest.de>
Date: Wed, 28 Feb 2024 08:30:33 +0000
Subject: [PATCH] Resolve #3765 "Ilias Schnittstelle: Probleme beim Anlegen der
 Nutzer Kategorie mit Ilias 8"

Closes #3765

Merge request studip/studip!2640
---
 app/controllers/my_ilias_accounts.php        | 9 +++++++--
 lib/ilias_interface/ConnectedIlias.class.php | 2 +-
 lib/ilias_interface/IliasSoap.class.php      | 7 ++++---
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/app/controllers/my_ilias_accounts.php b/app/controllers/my_ilias_accounts.php
index cc1a77a5f14..fc4c00d8294 100644
--- a/app/controllers/my_ilias_accounts.php
+++ b/app/controllers/my_ilias_accounts.php
@@ -184,9 +184,14 @@ class MyIliasAccountsController extends AuthenticatedController
                     '<a href="'.$this->ilias->getAbsolutePath().'">'.htmlReady($this->ilias->getName()).'</a>'
                 ));
             } elseif (!$session_id) {
-                PageLayout::postError(sprintf(_('Automatischer Login für %s-Installation (Nutzername %s) fehlgeschlagen.'),
+                PageLayout::postError(
+                    sprintf(
+                        _('Automatischer Login für %s-Installation (Nutzername %s) fehlgeschlagen.'),
                         htmlReady($this->ilias->getName()),
-                        htmlReady($this->ilias->user->getUsername())));
+                        htmlReady($this->ilias->user->getUsername())
+                    ),
+                    $this->ilias->getError()
+                );
             } elseif (($target == 'new') AND ! $module_id) {
                 PageLayout::postError(sprintf(_('Keine Kategorie zum Anlegen neuer Lernobjekte in der %s-Installation vorhanden.'),
                         htmlReady($this->ilias->getName())));
diff --git a/lib/ilias_interface/ConnectedIlias.class.php b/lib/ilias_interface/ConnectedIlias.class.php
index 09e15076bd0..5b9c1bf7429 100644
--- a/lib/ilias_interface/ConnectedIlias.class.php
+++ b/lib/ilias_interface/ConnectedIlias.class.php
@@ -503,7 +503,7 @@ class ConnectedIlias
      */
     public function newUserCategory()
     {
-        if (!$this->user->studip_login) {
+        if (!$this->user->isConnected()) {
             return false;
         }
         $this->soap_client->setCachingStatus(false);
diff --git a/lib/ilias_interface/IliasSoap.class.php b/lib/ilias_interface/IliasSoap.class.php
index 37d7c621aa1..f9ffccae86a 100644
--- a/lib/ilias_interface/IliasSoap.class.php
+++ b/lib/ilias_interface/IliasSoap.class.php
@@ -727,7 +727,7 @@ class IliasSoap extends StudipSoapClient
 
         $xml = "<!DOCTYPE Objects SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_object_0_1.dtd\">
 <Objects>
-  <Object type=\"$type\">
+  <Object type=\"$type\" obj_id=\"\">
     <Title>
     $title
     </Title>
@@ -768,7 +768,7 @@ class IliasSoap extends StudipSoapClient
 
         $xml = "<!DOCTYPE Objects SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_object_0_1.dtd\">
 <Objects>
-  <Object type=\"$type\">
+  <Object type=\"$type\" obj_id=\"\">
     <Title>
     $title
     </Title>
@@ -1652,7 +1652,8 @@ class IliasSoap extends StudipSoapClient
     {
         $param = [
             'sid'          => $this->getSID(),
-            'reference_id' => $id
+            'reference_id' => $id,
+            'user_id'      => 0
         ];
 
         $result = $this->call('getObjectByReference', $param);
-- 
GitLab