From 06d7582a1c628fac933868cc56cbd3135277b7e7 Mon Sep 17 00:00:00 2001
From: David Siegfried <david.siegfried@uni-vechta.de>
Date: Fri, 17 May 2024 11:59:30 +0000
Subject: [PATCH] remote AuxLockRules, fixes #4187

Closes #4187

Merge request studip/studip!3023
---
 RELEASE-NOTES.md                   |   2 +-
 lib/classes/AuxLockRules.class.php | 124 -----------------------------
 2 files changed, 1 insertion(+), 125 deletions(-)
 delete mode 100644 lib/classes/AuxLockRules.class.php

diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md
index d30f9295f04..d28e57f9c1a 100644
--- a/RELEASE-NOTES.md
+++ b/RELEASE-NOTES.md
@@ -54,7 +54,7 @@
   - `isSchedule ($sem_id, $presence_dates_only = TRUE, $clearcache = FALSE)`
   - `isMetadateCorrespondingDate ($termin_id, $begin = '', $end = '', $seminar_id='')`
   - `getPresenceTypes()`
-
+- Die Klasse `AuxLockRules` wurde ausgebaut. ([Issue #4187](https://gitlab.studip.de/studip/studip/-/issues/4187))
 
 ## Security related issues
 
diff --git a/lib/classes/AuxLockRules.class.php b/lib/classes/AuxLockRules.class.php
deleted file mode 100644
index 4d06ca2d9d2..00000000000
--- a/lib/classes/AuxLockRules.class.php
+++ /dev/null
@@ -1,124 +0,0 @@
-<?
-# Lifter002: DONE
-# Lifter007: TODO
-# Lifter003: TEST
-# Lifter010: TODO
-/**
-* ZusatzLockRules.class.php - Sichtbarkeits-Administration fuer Zusatzangaben bei Teilnehmerlisten
-*
-* Copyright (C) 2006 Till Glöggler <tgloeggl@inspace.de>
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License
-* as published by the Free Software Foundation; either version 2
-* of the License, or (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-*/
-
-/**
- * @deprecated since Stud.IP 5.3
- */
-class AuxLockRules
-{
-
-    static function _toArray($data)
-    {
-        return [
-            'lock_id' => $data['lock_id'],
-            'name' => $data['name'],
-            'description' => $data['description'],
-            'attributes' => json_decode($data['attributes'], true),
-            'order' => json_decode($data['sorting'], true)
-        ];
-    }
-
-    static function getAllLockRules()
-    {
-        $ret = [];
-        $db = DBManager::get()->query("SELECT * FROM aux_lock_rules");
-        while ($data = $db->fetch(PDO::FETCH_ASSOC)) {
-            $ret[$data['lock_id']] = AuxLockRules::_toArray($data);
-        }
-
-        return $ret;
-    }
-
-    static function getLockRuleById($id)
-    {
-        $stmt = DBManager::get()->prepare("SELECT * FROM aux_lock_rules WHERE lock_id = ?");
-        $stmt->execute([$id]);
-        $data = $stmt->fetch(PDO::FETCH_ASSOC);
-        return AuxLockRules::_toArray($data);
-    }
-
-    static function getLockRuleBySemId($sem_id)
-    {
-        $stmt = DBManager::get()->prepare("SELECT aux_lock_rule FROM seminare WHERE Seminar_id = ?");
-        $stmt->execute([$sem_id]);
-        $lock_rule = $stmt->fetchColumn();
-        if ($lock_rule) {
-            return AuxLockRules::getLockRuleById($lock_rule);
-        }
-        return NULL;
-    }
-
-    static function createLockRule($name, $description, $fields, $order)
-    {
-        $id = md5(uniqid(rand()));
-        $attributes = json_encode($fields);
-        $sorting = json_encode($order);
-        $stmt = DBManager::get()->prepare('INSERT INTO aux_lock_rules '
-                    . '(lock_id, name, description, attributes, sorting) '
-                . 'VALUES (?, ?, ?, ?, ?)');
-        $stmt->execute([$id, $name, $description, $attributes, $sorting]);
-        return $id;
-    }
-
-    static function updateLockRule($id, $name, $description, $fields, $order)
-    {
-        $attributes = json_encode($fields);
-        $sorting = json_encode($order);
-        $stmt = DBManager::get()->prepare('UPDATE aux_lock_rules '
-                    . 'SET name = ?, description = ?, attributes = ?, sorting = ? '
-                    . 'WHERE lock_id = ?');
-        return $stmt->execute([$name, $description, $attributes, $sorting, $id]);
-    }
-
-    static function deleteLockRule($id)
-    {
-        $stmt = DBManager::get()->prepare('SELECT COUNT(*) as c FROM seminare WHERE aux_lock_rule = ?');
-        $stmt->execute([$id]);
-        if ($stmt->fetchColumn() > 0) return false;
-
-        $stmt = DBManager::get()->prepare('DELETE FROM aux_lock_rules WHERE lock_id = ?');
-        return $stmt->execute([$id]);
-    }
-
-    static function getSemFields()
-    {
-        return [
-            'vasemester' => 'Semester',
-            'vanr' => 'Veranstaltungsnummer',
-            'vatitle' => 'Veranstaltungstitel',
-            'vadozent' => 'Dozent'
-        ];
-    }
-
-    static function checkLockRule($fields)
-    {
-        $entries = DataField::getDataFields('usersemdata');
-        foreach ($entries as $id => $entry) {
-            if ($fields[$entry->datafield_id] == 1) return true;
-        }
-
-        return false;
-    }
-}
-- 
GitLab