From b00266c5d7e3f69755ebd830328b2c6ba21892cc Mon Sep 17 00:00:00 2001
From: Raphael Dannecker <rdannecker@gmail.com>
Date: Fri, 27 Nov 2020 23:06:20 +0100
Subject: [PATCH] reformatting

---
 README.md            |  4 ++++
 upload_timetable.php | 24 +++++++++++-------------
 2 files changed, 15 insertions(+), 13 deletions(-)
 create mode 100644 README.md

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..64dfd1c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,4 @@
+# upload_timetable #
+
+upload_timetable is a helper script that pushes untis-exports to moodle when they have been changed.
+
diff --git a/upload_timetable.php b/upload_timetable.php
index 88c6d14..e3f7170 100644
--- a/upload_timetable.php
+++ b/upload_timetable.php
@@ -13,29 +13,27 @@ require_once('config.php');
 $MoodleRest = new MoodleRest($config['url'], $config['token']);
 
 if (file_exists ($config['hashfile'])) {
-	$hashfile = file_get_contents($config['hashfile']);
-	$hashes = (array) json_decode($hashfile);
+  $hashfile = file_get_contents($config['hashfile']);
+  $hashes = (array) json_decode($hashfile);
 } else $hashes = array();
 
 $untis_data = array('files' => array());
 foreach($config['files'] as $file) {
-	$content = file_get_contents($file['file']);
-	$hash = md5($content);
-	if (! array_key_exists($file['name'],$hashes) || $hashes[$file['name']] != $hash)
-	    $untis_data['files'][] = array('name' => $file['name'], 'content' => base64_encode($content));
-	$hashes[$file['name']] = $hash;
+  $content = file_get_contents($file['file']);
+  $hash = md5($content);
+  if (! array_key_exists($file['name'],$hashes) || $hashes[$file['name']] != $hash)
+    $untis_data['files'][] = array('name' => $file['name'], 'content' => base64_encode($content));
+  $hashes[$file['name']] = $hash;
 }
 
 if (count($untis_data['files'])) {
   $result = $MoodleRest->request('mod_timetable_update', $untis_data, MoodleRest::METHOD_POST);
   print_r($result);
   if (true) {
-	$hashfile = fopen($config['hashfile'],'w');
-	fwrite($hashfile, json_encode($hashes, JSON_FORCE_OBJECT));
-	fclose($hashfile);
+    $hashfile = fopen($config['hashfile'],'w');
+    fwrite($hashfile, json_encode($hashes, JSON_FORCE_OBJECT));
+    fclose($hashfile);
   }
 } else {
-	echo "Nothing to do\n";
+  echo "Nothing to do\n";
 }
-
-