From 613bcb61673043091b9a9cd76f647a26b419d347 Mon Sep 17 00:00:00 2001
From: Florian Dagner
Date: Tue, 30 Jan 2024 12:19:02 +0100
Subject: [PATCH] MBS-8543: Option added to pass on WLAN data via QR code
---
block_qr.php | 18 ++++++++++++++++--
edit_form.php | 40 +++++++++++++++++++++++++++++++++++++++-
lang/de/block_qr.php | 9 +++++++++
lang/en/block_qr.php | 10 +++++++++-
templates/qr.mustache | 16 ++++++++++++++++
version.php | 4 ++--
6 files changed, 91 insertions(+), 6 deletions(-)
diff --git a/block_qr.php b/block_qr.php
index d6cd2c3..e7d0f81 100644
--- a/block_qr.php
+++ b/block_qr.php
@@ -228,8 +228,19 @@ public function get_content() {
$qrcodelink .= $this->config->geolocation_br . '&mlon=' . $this->config->geolocation_lng;
$qrcodelink .= '#map=10/' . $this->config->geolocation_br . '/' . $this->config->geolocation_lng;
$qrurl = true;
- break;
}
+ break;
+
+ case 'wlan':
+ $qrcodecontent = "WIFI:T:" . $this->config->wlanauthentication;
+ $qrcodecontent .= ";S:" . $this->config->wlanssid;
+ $qrcodecontent .= ";P:" . $this->config->wlanpasskey;
+ $qrcodecontent .= ";H:" . $this->config->wlanssidoptions . ";";
+ $description .= get_string('wlan', 'block_qr');
+ $wlanauthentication = $this->config->wlanauthentication;
+ $wlanssid = $this->config->wlanssid;
+ $wlanpasskey = $this->config->wlanpasskey;
+ break;
}
// Short link option only in edit mode.
@@ -276,7 +287,10 @@ public function get_content() {
'qrcodelink' => $qrcodelink,
'urlshort' => $urlshort,
'fullview' => $fullview,
- 'configshortlink' => $configshortlink
+ 'configshortlink' => $configshortlink,
+ 'wlanauthentication' => $wlanauthentication,
+ 'wlanssid' => $wlanssid,
+ 'wlanpasskey' => $wlanpasskey,
];
$this->content->text = $OUTPUT->render_from_template('block_qr/qr', $data);
return $this->content;
diff --git a/edit_form.php b/edit_form.php
index b7e5c66..c5ae3b1 100644
--- a/edit_form.php
+++ b/edit_form.php
@@ -82,7 +82,8 @@ protected function specific_definition($mform) {
'internalcontent' => get_string('internalcontent', 'block_qr'),
'owncontent' => get_string('owncontent', 'block_qr'),
'event' => get_string('event', 'block_qr'),
- 'geolocation' => get_string('geolocation', 'block_qr')
+ 'geolocation' => get_string('geolocation', 'block_qr'),
+ 'wlan' => get_string('wlan', 'block_qr')
];
$courseid = $this->page->course->id;
if ($courseid == SITEID) {
@@ -174,6 +175,43 @@ protected function specific_definition($mform) {
$mform->hideIf('config_link', 'config_options', 'neq', 'geolocation');
$mform->setType('config_link', PARAM_TEXT);
+ // WLAN fields.
+ $mform->addElement('text', 'config_wlanssid', get_string('ssid_label', 'block_qr'), 'size="20"');
+ $mform->hideIf('config_wlanssid', 'config_options', 'neq', 'wlan');
+ $mform->setType('config_wlanssid', PARAM_NOTAGS);
+
+ $ssidoptions = [
+ 'false' => get_string('visible', 'block_qr'),
+ 'true' => get_string('hidden', 'block_qr'),
+ ];
+
+ $mform->addElement(
+ 'advcheckbox',
+ 'config_wlanssidoptions',
+ get_string('config_wlanssidoptions', 'block_qr'),
+ '',
+ $ssidoptions
+ );
+ $mform->hideIf('config_wlanssidoptions', 'config_options', 'neq', 'wlan');
+ $mform->setType('config_wlanssidoptions', PARAM_TEXT);
+ $mform->addElement('text', 'config_wlanpasskey', get_string('passkey_label', 'block_qr'), 'size="20"');
+ $mform->addHelpButton('config_wlanpasskey', 'wlan_passkey', 'block_qr');
+ $mform->hideIf('config_wlanpasskey', 'config_options', 'neq', 'wlan');
+ $mform->setType('config_wlanpasskey', PARAM_NOTAGS);
+ $authenticationoptions = [
+ 'nopass' => get_string('none', 'block_qr'),
+ 'WEP' => get_string('wep', 'block_qr'),
+ 'WPA/WPA2' => get_string('wpa', 'block_qr'),
+ ];
+ $mform->addElement(
+ 'select',
+ 'config_wlanauthentication',
+ get_string('config_wlanauthentication', 'block_qr'),
+ $authenticationoptions,
+ );
+ $mform->hideIf('config_wlanauthentication', 'config_options', 'neq', 'wlan');
+ $mform->setType('config_wlanauthentication', PARAM_TEXT);
+
// Section header title.
$mform->addElement('header', 'widthheader', get_string('settings', 'block_qr'));
// Settings.
diff --git a/lang/de/block_qr.php b/lang/de/block_qr.php
index f4d7394..b98d09c 100644
--- a/lang/de/block_qr.php
+++ b/lang/de/block_qr.php
@@ -23,6 +23,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+$string['config_wlanauthentication'] = 'Authentifizierung';
$string['allday'] = 'Ganztägig';
$string['codecontent'] = 'Inhalt';
$string['config_geolocation_br'] = 'Format and zulässige Werte';
@@ -31,6 +32,7 @@
$string['config_geolocation_lng_help'] = 'Der Wert für den Längengrad ist auf ±180 begrenzt. Die Eingabe erfolgt als Dezimalgrad mit einem Dezimalpunkt. Beispiel: 10.49184';
$string['config_link_label'] = 'Link zum Standort';
$string['config_size_label'] = 'Größe des QR-Codes';
+$string['config_wlanssidoptions'] = 'versteckt';
$string['courseurl'] = 'Link zu diesem Kurs';
$string['courseurldesc_help'] = 'Hier kann zum Beispiel der Kursname oder der Einschreibeschlüssel eingetragen werden.';
$string['courseurldesc_label'] = 'Beschreibung';
@@ -54,9 +56,11 @@
$string['medium'] = 'Mittel';
$string['nocontent'] = 'Es wurde noch kein Inhalt konfiguriert. Klicken Sie auf das Zahnrad, um einen Inhalt für diesen QR-Block zu konfigurieren.';
$string['nolink'] = 'Kein Link';
+$string['none'] = 'keine';
$string['osm'] = 'OpenStreetMap';
$string['owncontent'] = 'Text/Link';
$string['owncontent_label'] = 'Text oder Link beginnend mit "https://" einfügen';
+$string['passkey_label'] = 'Passwort';
$string['pluginname'] = 'QR-Code';
$string['privacy:metadata'] = 'Der Latest QR-Code-Block zeigt nur Daten an und speichert selbst keine Daten.';
$string['qr:addinstance'] = 'Einen neuen aktuellen QR-Code-Block hinzufügen';
@@ -65,6 +69,7 @@
$string['shortlinkservice'] = 'URL des Kurzlinkdienstes';
$string['shortlinkservice_description'] = 'Im Bearbeitungsmodus des Blocks kann ein Link zu einem Kurzlinkdienst angezeigt werden. Geben Sie dazu die URL des gewünschten Kurzlinkdienstes ein.Wenn dieser eine direkte Weitergabe der zu verkürzenden URL unterstützt, können Sie hierfür optional die Variable SHORTLINK verwenden und in den Link einbinden.';
$string['small'] = 'Klein';
+$string['ssid_label'] = 'SSID';
$string['strftimedate'] = 'd.m.y, H:i';
$string['strftimedateallday'] = 'd.m.y';
$string['strftimedatetime'] = 'H:i';
@@ -72,3 +77,7 @@
$string['urlparameterafter'] = 'URL-Parameter danach';
$string['urlparameterbefore'] = 'URL-Parameter davor';
$string['urlshortlabel'] = 'Kurzlink erstellen';
+$string['wlan'] = 'WLAN';
+$string['wep'] = 'WEP';
+$string['wpa'] = 'WPA/WPA2';
+$string['wlan_passkey_help'] = 'Veröffentlichen Sie keine Passwörter privater WLAN-Netzwerke!';
diff --git a/lang/en/block_qr.php b/lang/en/block_qr.php
index 01f1458..2602ac2 100644
--- a/lang/en/block_qr.php
+++ b/lang/en/block_qr.php
@@ -23,6 +23,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+$string['config_wlanauthentication'] = 'Authentication';
$string['allday'] = 'All day';
$string['codecontent'] = 'Content';
$string['config_geolocation_br'] = 'Format and permissible values';
@@ -31,6 +32,7 @@
$string['config_geolocation_lng_help'] = 'The value for the longitude is limited to ±180. The entry is made as a decimal degree with a decimal point. Example: 10.49184';
$string['config_link_label'] = 'Location link';
$string['config_size_label'] = 'Size of the qr code';
+$string['config_wlanssidoptions'] = 'hidden';
$string['courseurl'] = 'Link to this course';
$string['courseurldesc_help'] = 'For example, the course name or the enrolment key can be entered here.';
$string['courseurldesc_label'] = 'Description';
@@ -54,9 +56,11 @@
$string['medium'] = 'Medium';
$string['nocontent'] = 'No content has been configured yet. Click on the gear to configure a content for this QR block.';
$string['nolink'] = 'No Link';
+$string['none'] = 'none';
$string['osm'] = 'OpenStreetMap';
$string['owncontent'] = 'Text/URL';
$string['owncontent_label'] = 'Insert text or link starting with "https://"';
+$string['passkey_label'] = 'Password';
$string['pluginname'] = 'QR Code';
$string['privacy:metadata'] = 'The Latest QR Code block only shows data does not store data itself.';
$string['qr:addinstance'] = 'Add a new latest QR Code block';
@@ -65,6 +69,7 @@
$string['shortlinkservice'] = 'URL of the short link service';
$string['shortlinkservice_description'] = 'In the editing mode of the block, a link to a short link service can be displayed. To do this, enter the URL of the desired short link service.If this supports direct forwarding of the URL to be shortened, you can optionally use the SHORTLINK variable for this and include it in the link.';
$string['small'] = 'Small';
+$string['ssid_label'] = 'SSID';
$string['strftimedate'] = 'y-m-d, h:i A';
$string['strftimedateallday'] = 'y-m-d';
$string['strftimedatetime'] = 'h:i A';
@@ -72,4 +77,7 @@
$string['urlparameterafter'] = 'URL parameters after';
$string['urlparameterbefore'] = 'URL parameters before';
$string['urlshortlabel'] = 'Create short link';
-$string['view_label'] = 'Visible for course participants';
+$string['wlan'] = 'WiFi';
+$string['wep'] = 'WEP';
+$string['wpa'] = 'WPA/WPA2';
+$string['wlan_passkey_help'] = 'Do not publish passwords for private WiFi networks!';
diff --git a/templates/qr.mustache b/templates/qr.mustache
index ab2ea62..717e735 100644
--- a/templates/qr.mustache
+++ b/templates/qr.mustache
@@ -87,6 +87,22 @@
{{/geocoordinates}}
+{{#wlanssid}}
+
+
+ {{#str}}
+ ssid_label, block_qr
+ {{/str}}: {{{wlanssid}}}
+ {{#str}}
+ config_wlanauthentication, block_qr
+ {{/str}}: {{{wlanauthentication}}}
+ {{#str}}
+ passkey_label, block_qr
+ {{/str}}: {{{wlanpasskey}}}
+
+{{/wlanssid}}
+
+
{{#fullview}}
{{#configshortlink}}
diff --git a/version.php b/version.php
index cbe6892..fe7cf8e 100644
--- a/version.php
+++ b/version.php
@@ -26,7 +26,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->release = 'v0.0.1';
-$plugin->version = 2023042500; // The current plugin version (Date: YYYYMMDDXX).
+$plugin->version = 2024012900; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2022041200; // Requires this Moodle version.
$plugin->component = 'block_qr'; // Full name of the plugin (used for diagnostics).
-$plugin->maturity = MATURITY_ALPHA; // This is considered as ready for production sites.
+$plugin->maturity = MATURITY_BETA; // This is considered as ready for production sites.