From ad396a8233352243a030f8a6b6276bd2be201842 Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Tue, 10 May 2022 10:18:47 +0000
Subject: [PATCH] use user id as part of the selection id, fixes #986

Closes #986

Merge request studip/studip!569
---
 lib/models/MvvOverlappingSelection.class.php | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/models/MvvOverlappingSelection.class.php b/lib/models/MvvOverlappingSelection.class.php
index 4d0bd31daa3..936a2d81718 100644
--- a/lib/models/MvvOverlappingSelection.class.php
+++ b/lib/models/MvvOverlappingSelection.class.php
@@ -276,9 +276,10 @@ class MvvOverlappingSelection extends SimpleORMap
      * @param string $comp_versions The id of the compared version.
      * @param array|string $fachsems An array or a string with comma separated fachsem numbers.
      * @param array|string $semtypes An array or a string with comma separated course types.
+     * @param string|null $user_id User id that created the selection (defaults to current user)
      * @return string The md5 id.
      */
-    public static function createSelectionId($base_version, $comp_versions, $fachsems, $semtypes)
+    public static function createSelectionId($base_version, $comp_versions, $fachsems, $semtypes, string $user_id = null)
     {
         if (is_array($fachsems)) {
             sort($fachsems, SORT_NUMERIC);
@@ -302,7 +303,8 @@ class MvvOverlappingSelection extends SimpleORMap
             $base_version->id,
             $comp_versions,
             trim($fachsems) ? $fachsems : 'x',
-            trim($semtypes) ? $semtypes : 'x'
+            trim($semtypes) ? $semtypes : 'x',
+            $user_id ?? $GLOBALS['user']->id,
         ]));
     }
 
-- 
GitLab