From 96f24826a75cb1b6acd28730feb6b22e50524f66 Mon Sep 17 00:00:00 2001 From: Sagun Karki Date: Fri, 22 May 2026 10:33:59 +0200 Subject: [PATCH] fix: preserve blocked status of course members in updateCourse SOAP call (0040575) --- .../classes/class.ilCourseXMLParser.php | 12 +++- .../class.ilSoapCourseAdministration.php | 58 ++++++++++--------- 2 files changed, 43 insertions(+), 27 deletions(-) diff --git a/components/ILIAS/Course/classes/class.ilCourseXMLParser.php b/components/ILIAS/Course/classes/class.ilCourseXMLParser.php index 8978b6715683..1e5a06d4a3c1 100755 --- a/components/ILIAS/Course/classes/class.ilCourseXMLParser.php +++ b/components/ILIAS/Course/classes/class.ilCourseXMLParser.php @@ -1,6 +1,5 @@ @@ -54,6 +55,12 @@ class ilCourseXMLParser extends ilMDSaxParser implements ilSaxSubsetParser protected ilCourseWaitingList $course_waiting_list; protected ?ilAdvancedMDValueParser $adv_md_handler = null; protected array $course_members_array = []; + protected array $xml_mentioned_member_ids = []; + + public function getProcessedMemberIds(): array + { + return $this->xml_mentioned_member_ids; + } public function __construct(ilObjCourse $a_course_obj, string $a_xml_file = '') { @@ -440,6 +447,9 @@ private function handleTutor(array $a_attribs, array $id_data): void */ private function handleMember(array $a_attribs, array $id_data): void { + if (!empty($id_data['usr_id'])) { + $this->xml_mentioned_member_ids[] = $id_data['usr_id']; + } if (!isset($a_attribs['action']) || $a_attribs['action'] == 'Attach') { // if action not set, or set and attach if (!array_key_exists($id_data['usr_id'], $this->course_members_array)) { diff --git a/components/ILIAS/soap/classes/class.ilSoapCourseAdministration.php b/components/ILIAS/soap/classes/class.ilSoapCourseAdministration.php index 8c835af71828..3824d50dbe43 100755 --- a/components/ILIAS/soap/classes/class.ilSoapCourseAdministration.php +++ b/components/ILIAS/soap/classes/class.ilSoapCourseAdministration.php @@ -1,32 +1,20 @@ - * @version $Id$ - * @package ilias - */ + * This file is part of ILIAS, a powerful learning management system + * published by ILIAS open source e-Learning e.V. + * + * ILIAS is licensed with the GPL-3.0, + * see https://www.gnu.org/licenses/gpl-3.0.en.html + * You should have received a copy of said license along with the + * source code, too. + * + * If this is not the case or you just want to try ILIAS, you'll find + * us at: + * https://www.ilias.de + * https://github.com/ILIAS-eLearning + * + *********************************************************************/ class ilSoapCourseAdministration extends ilSoapAdministration { @@ -375,6 +363,15 @@ public function updateCourse(string $sid, int $course_id, string $xml) $md = new ilMD($tmp_course->getId(), 0, 'crs'); $md->deleteAll(); + $course_participants = ilCourseParticipants::_getInstanceByObjId($tmp_course->getId()); + $all_members = $course_participants->getParticipants(); + $blocked_users = []; + foreach ($all_members as $usr_id) { + if ($course_participants->isBlocked($usr_id)) { + $blocked_users[] = $usr_id; + } + } + ilCourseParticipants::_deleteAllEntries($tmp_course->getId()); ilCourseWaitingList::_deleteAll($tmp_course->getId()); @@ -384,6 +381,15 @@ public function updateCourse(string $sid, int $course_id, string $xml) $xml_parser->setMode(ilCourseXMLParser::MODE_SOAP); $xml_parser->setXMLContent($xml); $xml_parser->startParsing(); + + $xml_processed_members = $xml_parser->getProcessedMemberIds(); + $xml_lookup = array_flip($xml_processed_members); + $fresh_participants = ilCourseParticipants::_getInstanceByObjId($tmp_course->getId()); + foreach ($blocked_users as $usr_id) { + if (!isset($xml_lookup[$usr_id]) && $fresh_participants->isMember($usr_id)) { + $fresh_participants->updateBlocked($usr_id, true); + } + } $tmp_course->MDUpdateListener('General'); return true;