diff --git a/block_qr.php b/block_qr.php index d6cd2c3..2c25ba6 100644 --- a/block_qr.php +++ b/block_qr.php @@ -99,6 +99,9 @@ public function get_content() { $calendarend = null; $fullview = false; $svgsize = null; + $wifiauthentication = null; + $wifissid = null; + $wifipasskey = null; switch ($this->config->options) { case 'currenturl': @@ -228,8 +231,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 'wifi': + $qrcodecontent = "WIFI:T:" . $this->config->wifiauthentication; + $qrcodecontent .= ";S:" . $this->config->wifissid; + $qrcodecontent .= ";P:" . $this->config->wifipasskey; + $qrcodecontent .= ";H:" . $this->config->wifissidoptions . ";"; + $description .= get_string('wifi', 'block_qr'); + $wifiauthentication = $this->config->wifiauthentication; + $wifissid = $this->config->wifissid; + $wifipasskey = $this->config->wifipasskey; + break; } // Short link option only in edit mode. @@ -246,8 +260,12 @@ public function get_content() { if (empty($configshortlink)) { $urlshort = null; } else { - $encodedqrcodelink = urlencode($qrcodelink); - $urlshort = str_replace('SHORTLINK', $encodedqrcodelink, $configshortlink); + if ($qrcodelink !== null) { + $encodedqrcodelink = urlencode($qrcodelink); + $urlshort = str_replace('SHORTLINK', $encodedqrcodelink, $configshortlink); + } else { + $urlshort = null; + } } // Size of QR code. @@ -276,7 +294,10 @@ public function get_content() { 'qrcodelink' => $qrcodelink, 'urlshort' => $urlshort, 'fullview' => $fullview, - 'configshortlink' => $configshortlink + 'configshortlink' => $configshortlink, + 'wifiauthentication' => $wifiauthentication, + 'wifissid' => $wifissid, + 'wifipasskey' => $wifipasskey, ]; $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..d94f7e1 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'), + 'wifi' => get_string('wifi', 'block_qr'), ]; $courseid = $this->page->course->id; if ($courseid == SITEID) { @@ -174,6 +175,44 @@ protected function specific_definition($mform) { $mform->hideIf('config_link', 'config_options', 'neq', 'geolocation'); $mform->setType('config_link', PARAM_TEXT); + // Wifi fields. + $mform->addElement('text', 'config_wifissid', get_string('ssid_label', 'block_qr'), 'size="20"'); + $mform->hideIf('config_wifissid', 'config_options', 'neq', 'wifi'); + $mform->setType('config_wifissid', PARAM_NOTAGS); + + $ssidoptions = [ + 'false' => get_string('visible', 'block_qr'), + 'true' => get_string('hidden', 'block_qr'), + ]; + + $mform->addElement( + 'advcheckbox', + 'config_wifissidoptions', + get_string('config_wifissidoptions', 'block_qr'), + '', + $ssidoptions + ); + $mform->hideIf('config_wifissidoptions', 'config_options', 'neq', 'wifi'); + $mform->setType('config_wifissidoptions', PARAM_TEXT); + $mform->addElement('text', 'config_wifipasskey', get_string('passkey_label', 'block_qr'), 'size="20"'); + $mform->addHelpButton('config_wifipasskey', 'wifi_passkey', 'block_qr'); + $mform->hideIf('config_wifipasskey', 'config_options', 'neq', 'wifi'); + $mform->setType('config_wifipasskey', PARAM_NOTAGS); + $authenticationoptions = [ + 'WPA/WPA2' => get_string('wpa', 'block_qr'), + 'WEP' => get_string('wep', 'block_qr'), + 'nopass' => get_string('none', 'block_qr'), + + ]; + $mform->addElement( + 'select', + 'config_wifiauthentication', + get_string('config_wifiauthentication', 'block_qr'), + $authenticationoptions, + ); + $mform->hideIf('config_wifiauthentication', 'config_options', 'neq', 'wifi'); + $mform->setType('config_wifiauthentication', 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..aadaa0a 100644 --- a/lang/de/block_qr.php +++ b/lang/de/block_qr.php @@ -31,7 +31,10 @@ $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_wifiauthentication'] = 'Authentifizierung'; +$string['config_wifissidoptions'] = 'versteckt'; $string['courseurl'] = 'Link zu diesem Kurs'; +$string['courseurldesc'] = 'Beschreibung'; $string['courseurldesc_help'] = 'Hier kann zum Beispiel der Kursname oder der Einschreibeschlüssel eingetragen werden.'; $string['courseurldesc_label'] = 'Beschreibung'; $string['currenturl'] = 'Link zur aktuellen Seite'; @@ -54,9 +57,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 +70,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 +78,8 @@ $string['urlparameterafter'] = 'URL-Parameter danach'; $string['urlparameterbefore'] = 'URL-Parameter davor'; $string['urlshortlabel'] = 'Kurzlink erstellen'; +$string['wifi'] = 'WLAN'; +$string['wifi_passkey'] = "Umgang mit Passwörtern"; +$string['wifi_passkey_help'] = 'Veröffentlichen Sie keine Passwörter privater WLAN-Netzwerke!'; +$string['wep'] = 'WEP'; +$string['wpa'] = 'WPA/WPA2'; diff --git a/lang/en/block_qr.php b/lang/en/block_qr.php index 01f1458..df8fc9b 100644 --- a/lang/en/block_qr.php +++ b/lang/en/block_qr.php @@ -31,7 +31,10 @@ $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_wifiauthentication'] = 'Authentication'; +$string['config_wifissidoptions'] = 'hidden'; $string['courseurl'] = 'Link to this course'; +$string['courseurldesc'] = 'description'; $string['courseurldesc_help'] = 'For example, the course name or the enrolment key can be entered here.'; $string['courseurldesc_label'] = 'Description'; $string['currenturl'] = 'Link to the current page'; @@ -54,9 +57,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 +70,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 +78,8 @@ $string['urlparameterafter'] = 'URL parameters after'; $string['urlparameterbefore'] = 'URL parameters before'; $string['urlshortlabel'] = 'Create short link'; -$string['view_label'] = 'Visible for course participants'; +$string['wifi'] = 'WiFi'; +$string['wifi_passkey'] = "handling passwords"; +$string['wifi_passkey_help'] = 'Do not publish passwords for private WiFi networks!'; +$string['wep'] = 'WEP'; +$string['wpa'] = 'WPA/WPA2'; diff --git a/templates/qr.mustache b/templates/qr.mustache index ab2ea62..6902d57 100644 --- a/templates/qr.mustache +++ b/templates/qr.mustache @@ -87,6 +87,22 @@
{{/geocoordinates}} +{{#wifissid}} +
+
+ {{#str}}
+ ssid_label, block_qr
+ {{/str}}: {{{wifissid}}}
+ {{#str}}
+ config_wifiauthentication, block_qr
+ {{/str}}: {{{wifiauthentication}}}
+ {{#str}}
+ passkey_label, block_qr
+ {{/str}}: {{{wifipasskey}}}
+
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.