From c22252958da1c01b0cc9a0da4e891ea52f7ad09c Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Fri, 6 Jan 2023 16:56:40 +0000 Subject: [PATCH] remove RESOURCES_ENABLE_EXPERT_SCHEDULE_VIEW for good, fixes #1985 Closes #1985 Merge request studip/studip!1288 --- ...ble_expert_schedule_view_configuration.php | 35 +++++++++++++++++++ lib/models/CourseDate.class.php | 7 +--- lib/raumzeit/CycleDataDB.class.php | 5 ++- lib/raumzeit/MetaDate.class.php | 2 +- lib/raumzeit/SingleDate.class.php | 23 ++++++------ 5 files changed, 49 insertions(+), 23 deletions(-) create mode 100644 db/migrations/5.1.39_remove_resources_enable_expert_schedule_view_configuration.php diff --git a/db/migrations/5.1.39_remove_resources_enable_expert_schedule_view_configuration.php b/db/migrations/5.1.39_remove_resources_enable_expert_schedule_view_configuration.php new file mode 100644 index 00000000000..5c852b25b4f --- /dev/null +++ b/db/migrations/5.1.39_remove_resources_enable_expert_schedule_view_configuration.php @@ -0,0 +1,35 @@ +<?php +/** + * @see https://gitlab.studip.de/studip/studip/-/issues/1985 + */ +final class RemoveResourcesEnableExpertScheduleViewConfiguration extends Migration +{ + public function description() + { + return 'Removes the configuration RESOURCES_ENABLE_EXPERT_SCHEDULE_VIEW ' + . 'as well as RESOURCES_ALLOW_SEMASSI_SKIP_REQUEST'; + } + + protected function up() + { + $query = "DELETE `config`, `config_values` + FROM `config` + LEFT JOIN `config_values` USING (`field`) + WHERE `field` IN ( + 'RESOURCES_ENABLE_EXPERT_SCHEDULE_VIEW', + 'RESOURCES_ALLOW_SEMASSI_SKIP_REQUEST' + )"; + DBManager::get()->exec($query); + } + + protected function down() + { + $query = "INSERT INTO `config` (`field`, `value`, `type`, `range`, `section`, `mkdate`, `chdate`, `description`) + VALUES ('RESOURCES_ENABLE_EXPERT_SCHEDULE_VIEW', '0', 'boolean', 'global', 'resources', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), 'Enables the expert view of the course schedules')"; + DBManager::get()->exec($query); + + $query = "INSERT INTO `config` (`field`, `value`,`type`, `range`, `section`, `mkdate`, `chdate`, `description`) + VALUES ('RESOURCES_ALLOW_SEMASSI_SKIP_REQUEST', '1', 'boolean', 'global', 'resources', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), 'Schaltet das Pflicht, eine Raumanfrage beim Anlegen einer Veranstaltung machen zu müssen, ein oder aus')"; + DBManager::get()->exec($query); + } +} diff --git a/lib/models/CourseDate.class.php b/lib/models/CourseDate.class.php index 7acbb15149f..bcfe5c743a7 100644 --- a/lib/models/CourseDate.class.php +++ b/lib/models/CourseDate.class.php @@ -405,12 +405,7 @@ class CourseDate extends SimpleORMap implements PrivacyObject { $warnings = []; if (count($this->topics) > 0) { - if (Config::get()->RESOURCES_ENABLE_EXPERT_SCHEDULE_VIEW) { - $warnings[] = _('Diesem Termin ist im Ablaufplan ein Thema zugeordnet.') . "\n" - . _('Titel und Beschreibung des Themas bleiben erhalten und können in der Expertenansicht des Ablaufplans einem anderen Termin wieder zugeordnet werden.'); - } else { - $warnings[] = _('Diesem Termin ist ein Thema zugeordnet.'); - } + $warnings[] = _('Diesem Termin ist ein Thema zugeordnet.'); } if (Config::get()->RESOURCES_ENABLE && $this->getRoom()) { diff --git a/lib/raumzeit/CycleDataDB.class.php b/lib/raumzeit/CycleDataDB.class.php index 020919c047d..eb586b41929 100644 --- a/lib/raumzeit/CycleDataDB.class.php +++ b/lib/raumzeit/CycleDataDB.class.php @@ -130,11 +130,10 @@ class CycleDataDB * * @param string $metadate_id * @param int $timestamp - * @param boolean $keepIssues * * @return int number of deleted singledates */ - public static function deleteNewerSingleDates($metadate_id, $timestamp, $keepIssues = false) + public static function deleteNewerSingleDates($metadate_id, $timestamp) { $count = 0; @@ -145,7 +144,7 @@ class CycleDataDB $statement->execute([$metadate_id, $timestamp]); while ($termin_id = $statement->fetchColumn()) { $termin = new SingleDate($termin_id); - $termin->delete($keepIssues); + $termin->delete(); unset($termin); $count += 1; diff --git a/lib/raumzeit/MetaDate.class.php b/lib/raumzeit/MetaDate.class.php index 38a3a3d8afa..7e6fbbd2d0b 100644 --- a/lib/raumzeit/MetaDate.class.php +++ b/lib/raumzeit/MetaDate.class.php @@ -279,7 +279,7 @@ class MetaDate $singledate_count++; } // remove all SingleDates in the future for this CycleData - $count = CycleDataDB::deleteNewerSingleDates($data['cycle_id'], time(), true); + $count = CycleDataDB::deleteNewerSingleDates($data['cycle_id'], time()); // create new SingleDates $this->createSingleDates(['metadate_id' => $cycle->getMetaDateId(), 'startAfterTimeStamp' => time() diff --git a/lib/raumzeit/SingleDate.class.php b/lib/raumzeit/SingleDate.class.php index 289187fd58d..6740731e1be 100644 --- a/lib/raumzeit/SingleDate.class.php +++ b/lib/raumzeit/SingleDate.class.php @@ -270,31 +270,28 @@ class SingleDate return $this->metadate_id; } + /** + * @deprecated + */ function killIssue() { - // We delete the issue, cause there is no chance anybody can get to it without the expert view - if (!Config::get()->RESOURCES_ENABLE_EXPERT_SCHEDULE_VIEW) { - if ($issue_ids = $this->getIssueIDs()) { - foreach ($issue_ids as $issue_id) { - // delete this issue - unset($this->issues[$issue_id]); - $issue = new Issue(['issue_id' => $issue_id]); - $issue->delete(); - } + $issue_ids = $this->getIssueIDs(); + if (count($issue_ids) > 0) { + CourseTopic::deleteBySQL("issue_id IN (?)", $issue_ids); + + foreach ($issue_ids as $issue_id) { + unset($this->issues[$issue_id]); } } } - function delete($keepIssues = false) + function delete() { $cache = StudipCacheFactory::getCache(); $cache->expire('course/undecorated_data/' . $this->range_id); $this->chdate = time(); $this->killAssign(); - if (!$keepIssues) { - $this->killIssue(); - } return SingleDateDB::deleteSingleDate($this->termin_id, $this->ex_termin); } -- GitLab