Skip to content

Commit

Permalink
Fix for issue #8. Bumping version to 1.4.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
martignoni committed Oct 8, 2016
1 parent 650c407 commit 111f299
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 37 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The code is available at [https://github.com/martignoni/moodlebox-plugin](https:

### Release notes

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

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.

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).

## Features

* Info about the MoodleBox (kernel version, Raspbian version, free space on SD card, CPU load, CPU temperature, CPU frequency, uptime, DHCP clients).
Expand Down
95 changes: 60 additions & 35 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,21 @@ function definition() {
echo $OUTPUT->heading(get_string('datetimesetting', 'tool_moodlebox'));
echo $OUTPUT->box_start('generalbox');

$datetimesetform = new datetimeset_form();
$datetimesetform->display();

if ($data = $datetimesetform->get_data()) {
if (!empty($data->submitbutton)) {
$datecommand = "date +%s -s @$data->currentdatetime";
exec("echo $datecommand > .set-server-datetime");
\core\notification::warning(get_string('datetimemessage', 'tool_moodlebox'));
$datetimetriggerfilename = ".set-server-datetime";

if (file_exists($datetimetriggerfilename)) {
$datetimesetform = new datetimeset_form();
$datetimesetform->display();

if ($data = $datetimesetform->get_data()) {
if (!empty($data->submitbutton)) {
$datecommand = "date +%s -s @$data->currentdatetime";
file_put_contents($datetimetriggerfilename, "date +%s -s @$data->currentdatetime");
\core\notification::warning(get_string('datetimemessage', 'tool_moodlebox'));
}
}
} else {
echo $OUTPUT->notification(get_string('missingconfigurationerror', 'tool_moodlebox'));
}

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

$changepasswordform = new changepassword_form();
$changepasswordform->display();
$changepasswordtriggerfilename = ".newpassword";

if ($data = $changepasswordform->get_data()) {
if (!empty($data->submitbutton)) {
file_put_contents(".newpassword", $data->newpassword1);
\core\notification::warning(get_string('changepasswordmessage', 'tool_moodlebox'));
if (file_exists($changepasswordtriggerfilename)) {
$changepasswordform = new changepassword_form();
$changepasswordform->display();

if ($data = $changepasswordform->get_data()) {
if (!empty($data->submitbutton)) {
file_put_contents($changepasswordtriggerfilename, $data->newpassword1);
\core\notification::warning(get_string('changepasswordmessage', 'tool_moodlebox'));
}
} else if ($changepasswordform->is_submitted()) { // validation failed
\core\notification::error(get_string('changepassworderror', 'tool_moodlebox'));
}
} else if ($changepasswordform->is_submitted()) { // validation failed
\core\notification::error(get_string('changepassworderror', 'tool_moodlebox'));
} else {
echo $OUTPUT->notification(get_string('missingconfigurationerror', 'tool_moodlebox'));
}

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

$wifipasswordform = new wifipassword_form();
$wifipasswordform->display();
$wifipasswordtriggerfilename = ".wifipassword";

if (file_exists($wifipasswordtriggerfilename)) {
$wifipasswordform = new wifipassword_form();
$wifipasswordform->display();

if ($data = $wifipasswordform->get_data()) {
if (!empty($data->submitbutton)) {
// print_r($data);
file_put_contents(".wifipassword", $data->wifipassword);
\core\notification::warning(get_string('wifipasswordmessage', 'tool_moodlebox'));
if ($data = $wifipasswordform->get_data()) {
if (!empty($data->submitbutton)) {
// print_r($data);
file_put_contents($wifipasswordtriggerfilename, $data->wifipassword);
\core\notification::warning(get_string('wifipasswordmessage', 'tool_moodlebox'));
}
}
} else {
echo $OUTPUT->notification(get_string('missingconfigurationerror', 'tool_moodlebox'));
}

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

$restartshutdownform = new restartshutdown_form();
$restartshutdownform->display();
$reboottriggerfilename = ".reboot-server";
$shutdowntriggerfilename = ".shutdown-server";

if ($data = $restartshutdownform->get_data()) {
// idea from http://stackoverflow.com/questions/5226728/how-to-shutdown-ubuntu-with-exec-php
// adapted for use with incron
if (!empty($data->restartbutton)) {
exec('touch .reboot-server');
\core\notification::warning(get_string('restartmessage', 'tool_moodlebox'));
}
if (!empty($data->shutdownbutton)) {
exec('touch .shutdown-server');
\core\notification::warning(get_string('shutdownmessage', 'tool_moodlebox'));
if (file_exists($reboottriggerfilename) and file_exists($shutdowntriggerfilename)) {
$restartshutdownform = new restartshutdown_form();
$restartshutdownform->display();

if ($data = $restartshutdownform->get_data()) {
// idea from http://stackoverflow.com/questions/5226728/how-to-shutdown-ubuntu-with-exec-php
// adapted for use with incron
if (!empty($data->restartbutton)) {
exec("touch $reboottriggerfilename");
\core\notification::warning(get_string('restartmessage', 'tool_moodlebox'));
}
if (!empty($data->shutdownbutton)) {
exec("touch $shutdowntriggerfilename");
\core\notification::warning(get_string('shutdownmessage', 'tool_moodlebox'));
}
}
} else {
echo $OUTPUT->notification(get_string('missingconfigurationerror', 'tool_moodlebox'));
}

echo $OUTPUT->box_end();
Expand Down
1 change: 1 addition & 0 deletions lang/en/tool_moodlebox.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
$string['information'] = 'Information';
$string['kernelversion'] = 'Kernel version';
$string['moodleboxpluginversion'] = 'MoodleBox plugin version';
$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.';
$string['newwifipassword'] = 'New Wi-Fi password';
$string['nopassworddefined'] = 'No Wi-Fi password defined';
$string['parameter'] = 'Parameter';
Expand Down
1 change: 1 addition & 0 deletions lang/fr/tool_moodlebox.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
$string['information'] = 'Information';
$string['kernelversion'] = 'Version du noyau';
$string['moodleboxpluginversion'] = 'Version du plugin MoodleBox';
$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.';
$string['newwifipassword'] = 'Nouveau mot de passe Wi-Fi';
$string['nopassworddefined'] = 'Pas de mot de passe Wi-Fi défini';
$string['parameter'] = 'Paramètre';
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

defined('MOODLE_INTERNAL') || die;

$plugin->version = 2016251000;
$plugin->release = '1.4.1';
$plugin->version = 2016100800;
$plugin->release = '1.4.2';
$plugin->requires = 2015051103;
$plugin->maturity = MATURITY_STABLE;
$plugin->component = 'tool_moodlebox';

0 comments on commit 111f299

Please sign in to comment.