From 99622ed3fc5ab25d74cb9ec3b2ce50c06765eca1 Mon Sep 17 00:00:00 2001
From: Thijs Kinkhorst <thijs@kinkhorst.com>
Date: Mon, 16 Mar 2020 14:04:09 +0000
Subject: [PATCH] Remove now obsolete portal module

---
 .../portal/config-templates/module_portal.php |  12 --
 modules/portal/hooks/hook_htmlinject.php      |  49 -------
 modules/portal/lib/Portal.php                 | 124 ------------------
 3 files changed, 185 deletions(-)
 delete mode 100644 modules/portal/config-templates/module_portal.php
 delete mode 100644 modules/portal/hooks/hook_htmlinject.php
 delete mode 100644 modules/portal/lib/Portal.php

diff --git a/modules/portal/config-templates/module_portal.php b/modules/portal/config-templates/module_portal.php
deleted file mode 100644
index c934bf77b..000000000
--- a/modules/portal/config-templates/module_portal.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<?php
-
-/*
- * Configuration for the module portal.
- */
-
-$config = [
-    'pagesets' => [
-        ['frontpage_welcome', 'frontpage_config', 'frontpage_auth', 'frontpage_federation'],
-        ['sanitycheck', 'statistics'],
-    ],
-];
diff --git a/modules/portal/hooks/hook_htmlinject.php b/modules/portal/hooks/hook_htmlinject.php
deleted file mode 100644
index acd88405c..000000000
--- a/modules/portal/hooks/hook_htmlinject.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-use Webmozart\Assert\Assert;
-
-/**
- * Hook to inject HTML content into all pages...
- *
- * @param array &$hookinfo  hookinfo
- * @return void
- */
-function portal_hook_htmlinject(array &$hookinfo)
-{
-    Assert::keyExists($hookinfo, 'pre');
-    Assert::keyExists($hookinfo, 'post');
-    Assert::keyExists($hookinfo, 'page');
-
-    $links = ['links' => []];
-    \SimpleSAML\Module::callHooks('frontpage', $links);
-
-    Assert::isArray($links);
-
-    $portalConfig = \SimpleSAML\Configuration::getOptionalConfig('module_portal.php');
-
-    $allLinks = [];
-    foreach ($links as $ls) {
-        $allLinks = array_merge($allLinks, $ls);
-    }
-
-    $pagesets = $portalConfig->getValue('pagesets', [
-        ['frontpage_welcome', 'frontpage_config', 'frontpage_auth', 'frontpage_federation'],
-    ]);
-    \SimpleSAML\Module::callHooks('portalextras', $pagesets);
-    $portal = new \SimpleSAML\Module\portal\Portal($allLinks, $pagesets);
-
-    if (!$portal->isPortalized($hookinfo['page'])) {
-        return;
-    }
-
-    // Include jquery UI CSS files in header
-    $hookinfo['jquery']['css'] = true;
-
-    // Header
-    $hookinfo['pre'][] = '<div id="portalmenu" class="ui-tabs ui-widget ui-widget-content ui-corner-all">' .
-        $portal->getMenu($hookinfo['page']) .
-        '<div id="portalcontent" class="ui-tabs-panel ui-widget-content ui-corner-bottom">';
-
-    // Footer
-    $hookinfo['post'][] = '</div></div>';
-}
diff --git a/modules/portal/lib/Portal.php b/modules/portal/lib/Portal.php
deleted file mode 100644
index f397953fe..000000000
--- a/modules/portal/lib/Portal.php
+++ /dev/null
@@ -1,124 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace SimpleSAML\Module\portal;
-
-use SimpleSAML\Configuration;
-use SimpleSAML\Module;
-use SimpleSAML\Locale\Translate;
-
-class Portal
-{
-    /** @var array */
-    private $pages;
-
-    /** @var array|null */
-    private $config;
-
-
-    /**
-     * @param array $pages
-     * @param array|null $config
-     */
-    public function __construct(array $pages, array $config = null)
-    {
-        $this->pages = $pages;
-        $this->config = $config;
-    }
-
-
-    /**
-     * @param string $thispage
-     * @return array|null
-     */
-    public function getTabset(string $thispage): ?array
-    {
-        if (!isset($this->config)) {
-            return null;
-        }
-        foreach ($this->config as $set) {
-            if (in_array($thispage, $set, true)) {
-                return $set;
-            }
-        }
-        return null;
-    }
-
-
-    /**
-     * @param string $thispage
-     * @return bool
-     */
-    public function isPortalized(string $thispage): bool
-    {
-        if (!isset($this->config)) {
-            return false;
-        }
-        foreach ($this->config as $set) {
-            if (in_array($thispage, $set, true)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-
-    /**
-     * @param \SimpleSAML\Locale\Translate $translator
-     * @param string $thispage
-     * @return string
-     */
-    public function getLoginInfo(Translate $translator, string $thispage): string
-    {
-        $info = ['info' => '', 'translator' => $translator, 'thispage' => $thispage];
-        Module::callHooks('portalLoginInfo', $info);
-        return $info['info'];
-    }
-
-
-    /**
-     * @param string $thispage
-     * @return string
-     */
-    public function getMenu(string $thispage): string
-    {
-        $config = Configuration::getInstance();
-        $t = new Translate($config);
-        $tabset = $this->getTabset($thispage);
-        $logininfo = $this->getLoginInfo($t, $thispage);
-        $classes = 'tabset_tabs ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all';
-        $text = '<ul class="' . $classes . '">';
-        foreach ($this->pages as $pageid => $page) {
-            if (isset($tabset) && !in_array($pageid, $tabset, true)) {
-                continue;
-            }
-            $name = 'uknown';
-            if (isset($page['text'])) {
-                $name = $page['text'];
-            }
-            if (isset($page['shorttext'])) {
-                $name = $page['shorttext'];
-            }
-
-            /** @var string $name */
-            $name = $t->t($name);
-
-            if (!isset($page['href'])) {
-                $text .= '<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#">' .
-                    $name . '</a></li>';
-            } elseif ($pageid === $thispage) {
-                $text .= '<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#">' .
-                    $name . '</a></li>';
-            } else {
-                $text .= '<li class="ui-state-default ui-corner-top"><a href="' . $page['href'] . '">' .
-                    $name . '</a></li>';
-            }
-        }
-        $text .= '</ul>';
-        if (!empty($logininfo)) {
-            $text .= '<p class="logininfo" style="text-align: right; margin: 0px">' . $logininfo . '</p>';
-        }
-        return $text;
-    }
-}
-- 
GitLab