From 262a978f46870715ae2e6e735fee44fb11224da6 Mon Sep 17 00:00:00 2001 From: Thomas Hackl <hackl@data-quest.de> Date: Wed, 20 Apr 2022 09:17:41 +0200 Subject: [PATCH] configure if chat should be opened in an iframe or via button click --- migrations/03_use_matrix_chat_iframe.php | 47 ++++++++++++++++++++++++ plugin.manifest | 2 +- views/matrix_chat/index.php | 18 +++++---- 3 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 migrations/03_use_matrix_chat_iframe.php diff --git a/migrations/03_use_matrix_chat_iframe.php b/migrations/03_use_matrix_chat_iframe.php new file mode 100644 index 0000000..14bcd92 --- /dev/null +++ b/migrations/03_use_matrix_chat_iframe.php @@ -0,0 +1,47 @@ +<?php + +/** + * Class UseMatrixChatIframe + * Configure whether to use an iFrame for Matrix chat. + * instead of a password. + * + * 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. + * + * @author Thomas Hackl <hackl@data-quest.de> + * @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2 + * @category Matrix + */ + +class UseMatrixChatIframe extends Migration +{ + + public function description() + { + return 'Configure whether to use an iFrame for Matrix chat.'; + } + + public function up() + { + try { + Config::get()->create('MATRIX_USE_CHAT_IFRAME', [ + 'value' => '', + 'type' => 'boolean', + 'range' => 'global', + 'section' => 'matrix', + 'description' => 'Soll der Matrixchat in einem iFrame in Stud.IP geöffnet werden?' + ]); + } catch (Exception $e) { + } + + } + + public function down() + { + // Remove config entry. + Config::get()->delete('MATRIX_USE_CHAT_IFRAME'); + } + +} \ No newline at end of file diff --git a/plugin.manifest b/plugin.manifest index 43de2ca..251380b 100644 --- a/plugin.manifest +++ b/plugin.manifest @@ -1,7 +1,7 @@ pluginname=Matrix-Chat pluginclassname=MatrixPlugin origin=data-quest -version=0.96 +version=1.0 screenshot=assets/images/matrix_logo.png description=Matrix chat for Stud.IP courses studipMinVersion=4.5 diff --git a/views/matrix_chat/index.php b/views/matrix_chat/index.php index 6eef61a..c5eb6c3 100644 --- a/views/matrix_chat/index.php +++ b/views/matrix_chat/index.php @@ -45,11 +45,15 @@ <?= Assets::img('ajax-indicator-black.svg') ?> </div> <? elseif (!$noChat) : ?> - <div class="matrix-chat-button"> - <?= Studip\LinkButton::create( - dgettext('matrix', 'Chat öffnen'), - Config::get()->MATRIX_CHATSERVER_URL, - ['target' => '_blank'] - ) ?> - </div> + <? if (!Config::get()->MATRIX_USE_CHAT_IFRAME) : ?> + <iframe src="<?= Config::get()->MATRIX_CHATSERVER_URL ?>" width="100%" height="100%"></iframe> + <? else : ?> + <div class="matrix-chat-button"> + <?= Studip\LinkButton::create( + dgettext('matrix', 'Chat öffnen'), + Config::get()->MATRIX_CHATSERVER_URL, + ['target' => '_blank'] + ) ?> + </div> + <? endif ?> <? endif; -- GitLab