Skip to content
Snippets Groups Projects
Commit c2225295 authored by Jan-Hendrik Willms's avatar Jan-Hendrik Willms
Browse files

remove RESOURCES_ENABLE_EXPERT_SCHEDULE_VIEW for good, fixes #1985

Closes #1985

Merge request studip/studip!1288
parent b8809912
No related branches found
No related tags found
No related merge requests found
<?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);
}
}
...@@ -405,13 +405,8 @@ class CourseDate extends SimpleORMap implements PrivacyObject ...@@ -405,13 +405,8 @@ class CourseDate extends SimpleORMap implements PrivacyObject
{ {
$warnings = []; $warnings = [];
if (count($this->topics) > 0) { 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()) { if (Config::get()->RESOURCES_ENABLE && $this->getRoom()) {
$warnings[] = _('Dieser Termin hat eine Raumbuchung, welche mit dem Termin gelöscht wird.'); $warnings[] = _('Dieser Termin hat eine Raumbuchung, welche mit dem Termin gelöscht wird.');
......
...@@ -130,11 +130,10 @@ class CycleDataDB ...@@ -130,11 +130,10 @@ class CycleDataDB
* *
* @param string $metadate_id * @param string $metadate_id
* @param int $timestamp * @param int $timestamp
* @param boolean $keepIssues
* *
* @return int number of deleted singledates * @return int number of deleted singledates
*/ */
public static function deleteNewerSingleDates($metadate_id, $timestamp, $keepIssues = false) public static function deleteNewerSingleDates($metadate_id, $timestamp)
{ {
$count = 0; $count = 0;
...@@ -145,7 +144,7 @@ class CycleDataDB ...@@ -145,7 +144,7 @@ class CycleDataDB
$statement->execute([$metadate_id, $timestamp]); $statement->execute([$metadate_id, $timestamp]);
while ($termin_id = $statement->fetchColumn()) { while ($termin_id = $statement->fetchColumn()) {
$termin = new SingleDate($termin_id); $termin = new SingleDate($termin_id);
$termin->delete($keepIssues); $termin->delete();
unset($termin); unset($termin);
$count += 1; $count += 1;
......
...@@ -279,7 +279,7 @@ class MetaDate ...@@ -279,7 +279,7 @@ class MetaDate
$singledate_count++; $singledate_count++;
} }
// remove all SingleDates in the future for this CycleData // 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 // create new SingleDates
$this->createSingleDates(['metadate_id' => $cycle->getMetaDateId(), $this->createSingleDates(['metadate_id' => $cycle->getMetaDateId(),
'startAfterTimeStamp' => time() 'startAfterTimeStamp' => time()
......
...@@ -270,31 +270,28 @@ class SingleDate ...@@ -270,31 +270,28 @@ class SingleDate
return $this->metadate_id; return $this->metadate_id;
} }
/**
* @deprecated
*/
function killIssue() function killIssue()
{ {
// We delete the issue, cause there is no chance anybody can get to it without the expert view $issue_ids = $this->getIssueIDs();
if (!Config::get()->RESOURCES_ENABLE_EXPERT_SCHEDULE_VIEW) { if (count($issue_ids) > 0) {
if ($issue_ids = $this->getIssueIDs()) { CourseTopic::deleteBySQL("issue_id IN (?)", $issue_ids);
foreach ($issue_ids as $issue_id) { foreach ($issue_ids as $issue_id) {
// delete this issue
unset($this->issues[$issue_id]); unset($this->issues[$issue_id]);
$issue = new Issue(['issue_id' => $issue_id]);
$issue->delete();
}
} }
} }
} }
function delete($keepIssues = false) function delete()
{ {
$cache = StudipCacheFactory::getCache(); $cache = StudipCacheFactory::getCache();
$cache->expire('course/undecorated_data/' . $this->range_id); $cache->expire('course/undecorated_data/' . $this->range_id);
$this->chdate = time(); $this->chdate = time();
$this->killAssign(); $this->killAssign();
if (!$keepIssues) {
$this->killIssue();
}
return SingleDateDB::deleteSingleDate($this->termin_id, $this->ex_termin); return SingleDateDB::deleteSingleDate($this->termin_id, $this->ex_termin);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment