Skip to content

Commit 111f299

Browse files
committed
Fix for issue #8. Bumping version to 1.4.2.
1 parent 650c407 commit 111f299

File tree

5 files changed

+67
-37
lines changed

5 files changed

+67
-37
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The code is available at [https://github.com/martignoni/moodlebox-plugin](https:
1010

1111
### Release notes
1212

13+
* 2016-10-08, version 1.4.2: Display warnings when the plugin installation is not complete
1314
* 2016-09-25, version 1.4.1: MoodleBox Wi-Fi network password cannot be changed to empty
1415
* 2016-09-18, version 1.4: new option enabling to change the MoodleBox Wi-Fi network password
1516
* 2016-09-10, version 1.3: new option enabling to change the MoodleBox password
@@ -24,6 +25,8 @@ The code is available at [https://github.com/martignoni/moodlebox-plugin](https:
2425

2526
The MoodleBox plugin must be installed in the Moodle tree of the MoodleBox, in the _tool_ folder. Once installed, an new option _MoodleBox_ will be available in Moodle, under _Site administration > Server_ in the _Administration_ block.
2627

28+
To complete the installation, you have to create some files in the plugin folder and configure some incron jobs on the MoodleBox. These steps are described in the [documentation on creating a MoodleBox](https://github.com/martignoni/make-moodlebox/blob/master/doc/Moodlebox.pdf).
29+
2730
## Features
2831

2932
* Info about the MoodleBox (kernel version, Raspbian version, free space on SD card, CPU load, CPU temperature, CPU frequency, uptime, DHCP clients).

index.php

Lines changed: 60 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,21 @@ function definition() {
192192
echo $OUTPUT->heading(get_string('datetimesetting', 'tool_moodlebox'));
193193
echo $OUTPUT->box_start('generalbox');
194194

195-
$datetimesetform = new datetimeset_form();
196-
$datetimesetform->display();
197-
198-
if ($data = $datetimesetform->get_data()) {
199-
if (!empty($data->submitbutton)) {
200-
$datecommand = "date +%s -s @$data->currentdatetime";
201-
exec("echo $datecommand > .set-server-datetime");
202-
\core\notification::warning(get_string('datetimemessage', 'tool_moodlebox'));
195+
$datetimetriggerfilename = ".set-server-datetime";
196+
197+
if (file_exists($datetimetriggerfilename)) {
198+
$datetimesetform = new datetimeset_form();
199+
$datetimesetform->display();
200+
201+
if ($data = $datetimesetform->get_data()) {
202+
if (!empty($data->submitbutton)) {
203+
$datecommand = "date +%s -s @$data->currentdatetime";
204+
file_put_contents($datetimetriggerfilename, "date +%s -s @$data->currentdatetime");
205+
\core\notification::warning(get_string('datetimemessage', 'tool_moodlebox'));
206+
}
203207
}
208+
} else {
209+
echo $OUTPUT->notification(get_string('missingconfigurationerror', 'tool_moodlebox'));
204210
}
205211

206212
echo $OUTPUT->box_end();
@@ -209,16 +215,22 @@ function definition() {
209215
echo $OUTPUT->heading(get_string('changepasswordsetting', 'tool_moodlebox'));
210216
echo $OUTPUT->box_start('generalbox');
211217

212-
$changepasswordform = new changepassword_form();
213-
$changepasswordform->display();
218+
$changepasswordtriggerfilename = ".newpassword";
214219

215-
if ($data = $changepasswordform->get_data()) {
216-
if (!empty($data->submitbutton)) {
217-
file_put_contents(".newpassword", $data->newpassword1);
218-
\core\notification::warning(get_string('changepasswordmessage', 'tool_moodlebox'));
220+
if (file_exists($changepasswordtriggerfilename)) {
221+
$changepasswordform = new changepassword_form();
222+
$changepasswordform->display();
223+
224+
if ($data = $changepasswordform->get_data()) {
225+
if (!empty($data->submitbutton)) {
226+
file_put_contents($changepasswordtriggerfilename, $data->newpassword1);
227+
\core\notification::warning(get_string('changepasswordmessage', 'tool_moodlebox'));
228+
}
229+
} else if ($changepasswordform->is_submitted()) { // validation failed
230+
\core\notification::error(get_string('changepassworderror', 'tool_moodlebox'));
219231
}
220-
} else if ($changepasswordform->is_submitted()) { // validation failed
221-
\core\notification::error(get_string('changepassworderror', 'tool_moodlebox'));
232+
} else {
233+
echo $OUTPUT->notification(get_string('missingconfigurationerror', 'tool_moodlebox'));
222234
}
223235

224236
echo $OUTPUT->box_end();
@@ -227,15 +239,21 @@ function definition() {
227239
echo $OUTPUT->heading(get_string('wifipasswordsetting', 'tool_moodlebox'));
228240
echo $OUTPUT->box_start('generalbox');
229241

230-
$wifipasswordform = new wifipassword_form();
231-
$wifipasswordform->display();
242+
$wifipasswordtriggerfilename = ".wifipassword";
243+
244+
if (file_exists($wifipasswordtriggerfilename)) {
245+
$wifipasswordform = new wifipassword_form();
246+
$wifipasswordform->display();
232247

233-
if ($data = $wifipasswordform->get_data()) {
234-
if (!empty($data->submitbutton)) {
235-
// print_r($data);
236-
file_put_contents(".wifipassword", $data->wifipassword);
237-
\core\notification::warning(get_string('wifipasswordmessage', 'tool_moodlebox'));
248+
if ($data = $wifipasswordform->get_data()) {
249+
if (!empty($data->submitbutton)) {
250+
// print_r($data);
251+
file_put_contents($wifipasswordtriggerfilename, $data->wifipassword);
252+
\core\notification::warning(get_string('wifipasswordmessage', 'tool_moodlebox'));
253+
}
238254
}
255+
} else {
256+
echo $OUTPUT->notification(get_string('missingconfigurationerror', 'tool_moodlebox'));
239257
}
240258

241259
echo $OUTPUT->box_end();
@@ -244,20 +262,27 @@ function definition() {
244262
echo $OUTPUT->heading(get_string('restartstop', 'tool_moodlebox'));
245263
echo $OUTPUT->box_start('generalbox');
246264

247-
$restartshutdownform = new restartshutdown_form();
248-
$restartshutdownform->display();
265+
$reboottriggerfilename = ".reboot-server";
266+
$shutdowntriggerfilename = ".shutdown-server";
249267

250-
if ($data = $restartshutdownform->get_data()) {
251-
// idea from http://stackoverflow.com/questions/5226728/how-to-shutdown-ubuntu-with-exec-php
252-
// adapted for use with incron
253-
if (!empty($data->restartbutton)) {
254-
exec('touch .reboot-server');
255-
\core\notification::warning(get_string('restartmessage', 'tool_moodlebox'));
256-
}
257-
if (!empty($data->shutdownbutton)) {
258-
exec('touch .shutdown-server');
259-
\core\notification::warning(get_string('shutdownmessage', 'tool_moodlebox'));
268+
if (file_exists($reboottriggerfilename) and file_exists($shutdowntriggerfilename)) {
269+
$restartshutdownform = new restartshutdown_form();
270+
$restartshutdownform->display();
271+
272+
if ($data = $restartshutdownform->get_data()) {
273+
// idea from http://stackoverflow.com/questions/5226728/how-to-shutdown-ubuntu-with-exec-php
274+
// adapted for use with incron
275+
if (!empty($data->restartbutton)) {
276+
exec("touch $reboottriggerfilename");
277+
\core\notification::warning(get_string('restartmessage', 'tool_moodlebox'));
278+
}
279+
if (!empty($data->shutdownbutton)) {
280+
exec("touch $shutdowntriggerfilename");
281+
\core\notification::warning(get_string('shutdownmessage', 'tool_moodlebox'));
282+
}
260283
}
284+
} else {
285+
echo $OUTPUT->notification(get_string('missingconfigurationerror', 'tool_moodlebox'));
261286
}
262287

263288
echo $OUTPUT->box_end();

lang/en/tool_moodlebox.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
$string['information'] = 'Information';
4242
$string['kernelversion'] = 'Kernel version';
4343
$string['moodleboxpluginversion'] = 'MoodleBox plugin version';
44+
$string['missingconfigurationerror'] = 'This section isn\'t available. The plugin installation is not complete, so that the setting cannot be handled by the MoodleBox. Please read the <a href="https://github.com/martignoni/make-moodlebox/blob/master/doc/Moodlebox.pdf" target="_blank">documentation for building a MoodleBox</a> to fix this error.';
4445
$string['newwifipassword'] = 'New Wi-Fi password';
4546
$string['nopassworddefined'] = 'No Wi-Fi password defined';
4647
$string['parameter'] = 'Parameter';

lang/fr/tool_moodlebox.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
$string['information'] = 'Information';
4242
$string['kernelversion'] = 'Version du noyau';
4343
$string['moodleboxpluginversion'] = 'Version du plugin MoodleBox';
44+
$string['missingconfigurationerror'] = 'Cette section n\'est pas disponble, car l\'installation du plugin n\'est pas complète. Le réglage ne peut donc pas être traité par la MoodleBox. Veuillez consulter la <a href="https://github.com/martignoni/make-moodlebox/blob/master/doc/Moodlebox.pdf" target="_blank">documentation pour construire une MoodleBox</a> afin de corriger cette erreur.';
4445
$string['newwifipassword'] = 'Nouveau mot de passe Wi-Fi';
4546
$string['nopassworddefined'] = 'Pas de mot de passe Wi-Fi défini';
4647
$string['parameter'] = 'Paramètre';

version.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525

2626
defined('MOODLE_INTERNAL') || die;
2727

28-
$plugin->version = 2016251000;
29-
$plugin->release = '1.4.1';
28+
$plugin->version = 2016100800;
29+
$plugin->release = '1.4.2';
3030
$plugin->requires = 2015051103;
3131
$plugin->maturity = MATURITY_STABLE;
3232
$plugin->component = 'tool_moodlebox';

0 commit comments

Comments
 (0)