From cb26115a88a4ffb8844697b37eabbcf239cc74ec Mon Sep 17 00:00:00 2001
From: Moritz Strohm <strohm@data-quest.de>
Date: Fri, 5 Nov 2021 12:18:53 +0000
Subject: [PATCH] TIC #395: removed ACCESSKEY_ENABLED config

---
 app/controllers/settings/general.php          |  1 -
 app/views/settings/general.php                | 13 ---------
 .../5.1.8_remove_access_key_enable.php        | 27 +++++++++++++++++++
 db/studip_default_data.sql                    |  1 -
 lib/include/header.php                        |  3 ---
 templates/header-navigation-item.php          | 11 --------
 templates/header.php                          |  4 +--
 7 files changed, 29 insertions(+), 31 deletions(-)
 create mode 100644 db/migrations/5.1.8_remove_access_key_enable.php

diff --git a/app/controllers/settings/general.php b/app/controllers/settings/general.php
index dae18b49d10..3c17eb66dab 100644
--- a/app/controllers/settings/general.php
+++ b/app/controllers/settings/general.php
@@ -63,7 +63,6 @@ class Settings_GeneralController extends Settings_SettingsController
         }
 
         $this->config->store('PERSONAL_STARTPAGE', Request::int('personal_startpage'));
-        $this->config->store('ACCESSKEY_ENABLE', Request::int('accesskey_enable'));
         $this->config->store('SHOWSEM_ENABLE', Request::int('showsem_enable'));
         $this->config->store('SKIPLINKS_ENABLE', Request::int('skiplinks_enable'));
         $this->config->store('TOUR_AUTOSTART_DISABLE', Request::int('tour_autostart_disable'));
diff --git a/app/views/settings/general.php b/app/views/settings/general.php
index 5348975873a..a03ccf7a7b4 100644
--- a/app/views/settings/general.php
+++ b/app/views/settings/general.php
@@ -57,19 +57,6 @@ $start_pages = [
                 .'Zusätzlich wird der aktive Bereich einer Seite hervorgehoben.')) ?>
         </label>
 
-        <label>
-            <input type="checkbox" name="accesskey_enable"
-                   aria-describedby="accesskey_enable_description" value="1"
-                <? if ($config->ACCESSKEY_ENABLE) echo 'checked'; ?>>
-            <?= _('Tastenkombinationen für Hauptfunktionen') ?>
-            <?= tooltipHtmlIcon(_('Mit dieser Einstellung können Sie für die meisten in der Kopfzeile '
-                .'erreichbaren Hauptfunktionen eine Bedienung über Tastenkombinationen '
-                .'aktivieren. <br>Die Tastenkombination wird im Tooltip des jeweiligen '
-                .'Icons angezeigt.')." "._('Diese kann für jeden Browser und jedes Betriebssystem unterschiedlich '
-                    .'sein (siehe <a href="http://en.wikipedia.org/wiki/Accesskey" '
-                    .'target="_blank" rel="noopener noreferrer">Wikipedia</a>).')) ?>
-        </label>
-
         <label>
             <input type="checkbox"
                    name="showsem_enable"
diff --git a/db/migrations/5.1.8_remove_access_key_enable.php b/db/migrations/5.1.8_remove_access_key_enable.php
new file mode 100644
index 00000000000..c1f86246d3a
--- /dev/null
+++ b/db/migrations/5.1.8_remove_access_key_enable.php
@@ -0,0 +1,27 @@
+<?php
+
+class RemoveAccessKeyEnable extends Migration
+{
+    public function description()
+    {
+        return 'Removes ACCESSKEY_ENABLE';
+    }
+
+    public function up()
+    {
+        $db = DBManager::get();
+        $db->exec("DELETE FROM `config_values` WHERE `field` = 'ACCESSKEY_ENABLE'");
+        $db->exec("DELETE FROM `config` WHERE `field` = 'ACCESSKEY_ENABLE'");
+    }
+
+    public function down()
+    {
+        $db = DBManager::get();
+        $db->exec(
+            "INSERT INTO `config`
+            (`field`, `type`, `value`, `range`, `description`)
+            VALUES
+            ('ACCESSKEY_ENABLE', 'boolean', '', 'user', ' Schaltet die Nutzung von Shortcuts für einen User ein oder aus, Systemdefault')"
+        );
+    }
+}
diff --git a/db/studip_default_data.sql b/db/studip_default_data.sql
index 6b1706d55ac..6a050f7ede8 100644
--- a/db/studip_default_data.sql
+++ b/db/studip_default_data.sql
@@ -127,7 +127,6 @@ INSERT INTO `colour_values` (`colour_id`, `description`, `value`, `mkdate`, `chd
 -- Dumping data for table `config`
 --
 
-INSERT INTO `config` (`field`, `value`, `type`, `range`, `section`, `mkdate`, `chdate`, `description`) VALUES('ACCESSKEY_ENABLE', '', 'boolean', 'user', '', 0, 0, 'Schaltet die Nutzung von Shortcuts für einen User ein oder aus, Systemdefault');
 INSERT INTO `config` (`field`, `value`, `type`, `range`, `section`, `mkdate`, `chdate`, `description`) VALUES('ADMIN_COURSES_SHOW_COMPLETE', '1', 'boolean', 'global', 'global', 1462287310, 1462287310, 'Definiert, ob auf der Admin-Veranstaltunggseite der Komplett-Status für Veranstaltungen aufgeführt sein soll');
 INSERT INTO `config` (`field`, `value`, `type`, `range`, `section`, `mkdate`, `chdate`, `description`) VALUES('ADMIN_COURSES_SIDEBAR_ACTIVE_ELEMENTS', '', 'string', 'user', '', 0, 0, 'Diese Einstellung legt fest, welche Elemente in der Seitenleiste der Veranstaltungsübersicht für Admins sichtbar sind.');
 INSERT INTO `config` (`field`, `value`, `type`, `range`, `section`, `mkdate`, `chdate`, `description`) VALUES('ADMISSION_PRELIM_COMMENT_ENABLE', '1', 'boolean', 'global', '', 1153814966, 1153814966, 'Schaltet ein oder aus, ob ein Nutzer im Modus \"Vorläufiger Eintrag\" eine Bemerkung hinterlegen kann');
diff --git a/lib/include/header.php b/lib/include/header.php
index 5a90479747b..c0046fb3f97 100644
--- a/lib/include/header.php
+++ b/lib/include/header.php
@@ -46,9 +46,6 @@ if (PageLayout::isHeaderEnabled()) //Einige Seiten benötigen keinen Header, spr
                 $header_template->public_hint = _('öffentliche Veranstaltung');
             }
         }
-        if ($GLOBALS['user']->cfg->ACCESSKEY_ENABLE) {
-            $header_template->accesskey_enabled = true;
-        }
 
         if (!$GLOBALS['user']->needsToAcceptTerms()) {
             $header_template->show_quicksearch = true;
diff --git a/templates/header-navigation-item.php b/templates/header-navigation-item.php
index 9b2157cdb32..a163140efee 100644
--- a/templates/header-navigation-item.php
+++ b/templates/header-navigation-item.php
@@ -4,17 +4,6 @@ $attributes = $nav->getLinkAttributes();
 $image_attributes = $nav->getImage()->getAttributes();
 $attributes['title'] = $image_attributes['title'];
 
-if ($accesskey_enabled) {
-    if (!isset($GLOBALS['accesskey-count'])) {
-        $GLOBALS['accesskey-count'] = 1;
-    }
-
-    if ($GLOBALS['accesskey-count'] < 10) {
-        $attributes['title'] = "{$attributes['title']}  [ALT] + {$GLOBALS['accesskey-count']}";
-        $attributes['accesskey'] = $GLOBALS['accesskey-count']++;
-    }
-}
-
 // Add badge number to link attributes
 if ($nav->getBadgeNumber()) {
     $attributes['data-badge'] = (int)$nav->getBadgeNumber();
diff --git a/templates/header.php b/templates/header.php
index 9ba491c5738..87005524252 100644
--- a/templates/header.php
+++ b/templates/header.php
@@ -153,7 +153,7 @@ if (isset($_COOKIE['navigation-length'])) {
     <? foreach ($header_nav['visible'] as $path => $nav): ?>
         <?= $this->render_partial(
             'header-navigation-item.php',
-            compact('path', 'nav', 'accesskey_enabled')
+            compact('path', 'nav')
         ) ?>
     <? endforeach; ?>
         <li class="overflow">
@@ -175,7 +175,7 @@ if (isset($_COOKIE['navigation-length'])) {
             <? foreach ($header_nav['hidden'] as $path => $nav) : ?>
                 <?= $this->render_partial(
                     'header-navigation-item.php',
-                    compact('path', 'nav', 'accesskey_enabled')
+                    compact('path', 'nav')
                 ) ?>
             <? endforeach; ?>
             </ul>
-- 
GitLab