Skip to content

Commit

Permalink
Merge pull request #9 from mebis-lp/MBS-8543_WLAN
Browse files Browse the repository at this point in the history
MBS-8543: Option added to pass on WLAN data via QR code
  • Loading branch information
sh-csg authored Mar 11, 2024
2 parents 1c854dd + 53c0f30 commit 91ad403
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 8 deletions.
29 changes: 25 additions & 4 deletions block_qr.php
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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;
Expand Down
41 changes: 40 additions & 1 deletion edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions lang/de/block_qr.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand All @@ -65,10 +70,16 @@
$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.</br>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';
$string['thisurl'] = 'Link zu dieser Seite';
$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';
12 changes: 11 additions & 1 deletion lang/en/block_qr.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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';
Expand All @@ -65,11 +70,16 @@
$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.</br>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';
$string['thisurl'] = 'Link to this page';
$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';
16 changes: 16 additions & 0 deletions templates/qr.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,22 @@
</p>
{{/geocoordinates}}

{{#wifissid}}
<p class="text-left">
<b>
{{#str}}
ssid_label, block_qr
{{/str}}: </b>{{{wifissid}}}<br><b>
{{#str}}
config_wifiauthentication, block_qr
{{/str}}: </b> {{{wifiauthentication}}}<br><b>
{{#str}}
passkey_label, block_qr
{{/str}}: </b> {{{wifipasskey}}}<br>
</p>
{{/wifissid}}


{{#fullview}}
{{#configshortlink}}
<p class="text-center">
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.

0 comments on commit 91ad403

Please sign in to comment.