commit 784cb23da30890986e5bd754861990abf9b14410
Author: root <root@moodle.steinbeisschule-reutlingen.de>
Date:   Fri Jun 26 11:30:19 2020 +0000

    Initial commit of timetable-Module (rd)

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..9a41604
--- /dev/null
+++ b/README.md
@@ -0,0 +1,4 @@
+Moodle Block Timetable
+======================
+
+This Module provides a timetable based on untis export-files: lesson.txt, substitution.txt
diff --git a/block_timetable.php b/block_timetable.php
new file mode 100644
index 0000000..b465d77
--- /dev/null
+++ b/block_timetable.php
@@ -0,0 +1,190 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Newblock block caps.
+ *
+ * @package    block_timetable
+ * @copyright  Daniel Neis <danielneis@gmail.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+use block_timetable\timetable;
+
+class block_timetable extends block_base {
+
+    function init() {
+        $this->title = get_string('pluginname', 'block_timetable');
+    }
+
+    function get_content() {
+        global $CFG, $OUTPUT;
+
+        if ($this->content !== null) {
+            return $this->content;
+        }
+
+        if (empty($this->instance)) {
+            $this->content = '';
+            return $this->content;
+        }
+
+        $this->content = new stdClass();
+        $this->content->items = array();
+        $this->content->icons = array();
+        $this->content->footer = 'Faecher<br>Lehrer<br>Raeume';
+
+        // user/index.php expect course context, so get one if page has module context.
+	$currentcontext = $this->page->context->get_course_context(false);
+
+
+        if (! empty($this->config->text)) {
+            $this->content->text = $this->config->text;
+        }
+
+        $this->content->text = '';
+        if (empty($currentcontext)) {
+            return $this->content;
+        }
+        if ($this->page->course->id == SITEID) {
+            $this->content->text .= "site context";
+	}
+        if ($this->page->course->idnumber && $this->page->course->shortname) {
+		$class = $this->page->course->shortname;
+		$class = 'TG11/3';
+            $this->content->text .= "Stundenplan der Klasse $class<br>";
+	} //elseif ($USER->
+
+	//$context_id = get_context_instance_by_id($course->id);
+	//echo "Contextid = $contextid->contextlevel\n";
+
+	/*
+	// Verbindung zu localhost auf port 3307
+	$mysqli = new mysqli('mistral:3307', 'timetable_user1', 'd7jzRYpfGS3OkIpHCBEE','timetable');
+	if ($mysqli->connect_errno) {
+	     $this->content->text .= 'Verbindung schlug fehl: ' . $mysqli->connect_errno;
+	}
+	 */
+	$period_max = get_config('timetable', 'numperiod');
+	$table = new html_table();
+	$table->cellspacing = 0;
+	$table->cellpadding = 0;
+	$table->attributes['cellpadding'] = '0';
+	$table->attributes['class'] = 'minicalendar calendartable';
+//	$table->align = array('right','center','center','center','center','center');
+//	$table->size = array('50', '50');
+	$table->head = array('','Mo','Di', 'Mi' , 'Do', 'Fr');
+	for ($i = 1; $i <= $period_max; $i++) {
+		$tablerow = new \html_table_row();
+		$tablerow->cells[] = new html_table_cell($i);
+		for ($k = 1; $k <= 5; $k++) {
+			//$cell = new html_table_cell("$i+$k");
+			$cell = new html_table_cell("");
+			$cell->abbr = "";
+//			$cell->attributes['class'] = 'day text-center';
+			$tablerow->cells[] = $cell;
+			//$tablerow->cells[] = '<td class="day text-center">'+"$i+$k</td>";
+			//$tablerow->cells[] = new html_table_cell("$i+$k");
+		}
+		$table->data[] = $tablerow;
+	}
+	//$sql = "Select * from lesson where teacher = 'Hbr' and not (mid(week, 36, 1) = '0')";
+	$sql = "teacher = 'Hbr' and not (mid(week, 26, 1) = '0')";
+	if ($class) {
+		//$sql = "Select * from lesson where class = '$class' and not (mid(week, 37, 1) = '0')";
+		$sql = "class = '$class' and not (mid(week, 26, 1) = '0')";
+	}
+	global $DB;
+	if ($result = $DB->get_records_select('timetable_lesson',$sql)) {
+		foreach ($result as $lesson) {
+			if ($lesson->period < $period_max) {
+				if ($table->data[$lesson->period-1]->cells[$lesson->day]->text)
+				       $table->data[$lesson->period-1]->cells[$lesson->day]->text .= "<BR>";
+				$table->data[$lesson->period-1]->cells[$lesson->day]->text .= $lesson->subject;
+			}
+
+		}
+	} else {
+		echo "get_records_select failed\n";
+	}
+	for ($i = 0; $i < $period_max; $i++) {
+		for ($k = 1; $k <= 5; $k++) {
+			if (!$table->data[$i]->cells[$k]->text) $table->data[$i]->cells[$k]->text = "-";
+		}
+	}
+
+/*
+	if (!$result = $mysqli->query($sql)) {
+	    // Oh no! The query failed. 
+	     $this->content->text .=  "Sorry, the website is experiencing problems.";
+	}
+	while ($lesson = $result->fetch_assoc()) {
+//		if ($lesson['period']<5 && $lesson['day']<5);
+		//$table->data[$lesson['period']-1]->cells[$lesson['day']]->text = $lesson['subject'];
+		//$table->data[$lesson['period']-1]->cells[$lesson['day']]->text = $lesson['room'];
+		$table->data[$lesson['period']-1]->cells[$lesson['day']]->text = $lesson['class'];
+	}
+ */	
+
+	//$table->data = array($row1, $row2);
+	$date = new DateTime();
+	$monday = new DateTime();
+	$friday = new DateTime();
+	$week = $date->format("W");
+	$dayofweek = $date->format('w')-1;
+	
+	$monday->sub(new DateInterval("P{$dayofweek}D"));
+	$friday->add(new DateInterval("P".(4-$dayofweek)."D"));
+	$this->content->text .= $monday->format('d.m') . " - " . $friday->format('d.m');
+	$ttable = new timetable('class','TG11/3');
+	$ttable->read_db($week);
+	$this->content->text .= html_writer::start_tag('div', ['data-region' => 'calendar', 'class' => 'maincalendar']);	
+	$this->content->text .= $ttable->print_table('subject');
+	//$this->content->text .= html_writer::table($table);
+	$this->content->text .= html_writer::end_tag('div');
+	
+	//$this->content->text .= file_get_contents("/var/www/plaene/25/c/mc00005.htm");
+	//$mysqli->close();
+        return $this->content;
+    }
+
+    // my moodle can only have SITEID and it's redundant here, so take it away
+    public function applicable_formats() {
+        return array('all' => false,
+                     'site' => true,
+                     'site-index' => true,
+                     'course-view' => true, 
+                     'course-view-social' => false,
+                     'mod' => true, 
+                     'mod-quiz' => false);
+    }
+
+    public function instance_allow_multiple() {
+          return true;
+    }
+
+    function has_config() {return true;}
+
+    public function cron() {
+            mtrace( "Hey, my cron script is running" );
+             
+                 // do something
+                  
+                      return true;
+    }
+}
diff --git a/classes/task/import_data.php b/classes/task/import_data.php
new file mode 100644
index 0000000..87e4743
--- /dev/null
+++ b/classes/task/import_data.php
@@ -0,0 +1,91 @@
+<?php
+
+namespace block_timetable\task;
+ 
+/**
+ * An example of a scheduled task.
+ */
+class import_data extends \core\task\scheduled_task {
+ 
+  /**
+  * Return the task's name as shown in admin screens.
+  *
+  * @return string
+  */
+  public function get_name() {
+     return get_string('import_data', 'block_timetable');
+  }
+ 
+  /**
+   * Execute the task.
+   */
+  public function execute() {
+     global $DB;
+     $lastmtime = get_config('block_timetable', 'lastmtime');
+     $filename = get_config('timetable', 'fnamelesson');
+     echo $filename;
+     if (!$filename) return;
+     //$filename = "/srv/stundenplan/lesson.txt"; 
+     echo "Lastmtime = $lastmtime\n";
+     if (file_exists ( $filename )) {
+	$mtime = filemtime ( $filename );
+        echo "mtime = $mtime\n";
+	if ($mtime<=$lastmtime) return;	
+	echo "after return\n";
+	try {
+ 	   $transaction = $DB->start_delegated_transaction();
+	   echo "before delete\n";
+	   $DB->delete_records_select("timetable_lesson", "id>0");
+	   echo "after delete\n";
+	   $handle = @fopen($filename, "r");	   
+	   echo "after handle\n";
+	   while (($buffer = fgets($handle, 4096)) !== false) {
+//	      echo $buffer;
+	      $buffer = utf8_encode(rtrim($buffer));
+	      $data = explode("\t", $buffer);
+//	      echo "Num elements: ".count($data)."\n";
+	      if (count($data) != 10) throw new Exception('Wrong size of elements');
+//	      echo "after count data \n";
+//	      echo "data 0 =$data[0]\n";
+
+	      /*
+	      $dataobject = new stdClass();
+	      //$dataobject = new object;
+	      $dataobject->teacher = $data[0];
+	      $dataobject->day     = $data[1];
+	      $dataobject->period  = $data[2];
+	      $dataobject->subject = $data[3];
+	      $dataobject->room    = $data[4];
+	      $dataobject->lessonid= $data[5];
+	      $dataobject->flag    = $data[6];
+	      $dataobject->class   = $data[7];
+	      $dataobject->week    = $data[8];
+	      $dataobject->unknown = $data[9];
+	       */ 
+	      $dataobject = (object)array('teacher' => $data[0], 
+		      			  'day'     => $data[1],
+		      			  'period'  => $data[2],
+		      			  'subject' => $data[3],
+		      			  'room'    => $data[4],
+		      			  'lessonid'=> $data[5],
+		      			  'flag'    => $data[6],
+		      			  'class'   => $data[7],
+		      			  'week'    => $data[8],
+					  'unknown' => $data[9]);
+	       
+//	      echo "after dataobject\n";
+	      $DB->insert_record("timetable_lesson", $dataobject);
+	   }
+	   $transaction->allow_commit();
+	   $lastmtime = $mtime;
+	   set_config('lastmtime', $lastmtime, 'block_timetable');
+	} catch(Exception $e) {
+	   $transaction->rollback($e);
+	}
+
+     }
+   // Apply fungus cream.
+   // Apply chainsaw.
+   // Apply olive oil.
+  }
+}
diff --git a/classes/timetable.php b/classes/timetable.php
new file mode 100755
index 0000000..74b47cc
--- /dev/null
+++ b/classes/timetable.php
@@ -0,0 +1,98 @@
+<?php
+
+/**
+ * File containing timetable class.
+ *
+ * @package    block_online_users
+ * @copyright  1999 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+namespace block_timetable;
+
+defined('MOODLE_INTERNAL') || die();
+
+/**
+ * Class used to list and count online users
+ *
+ * @package    block_online_users
+ * @copyright  1999 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class timetable {
+
+    /** @var array the data of timetable */
+    public $data;
+
+    /**
+     * Class constructor
+     *
+     * @param string $type The type of the timetable [class, room, teacher]
+     * @param int $name Name of class or room or teacher
+     */
+    public function __construct($type, $name) {
+	$this->type = $type;
+	$this->name = $name;
+	$this->periodmax=0;
+	$this->data = array();
+	for ($i=1; $i<6; $i++) $this->data[$i] = array();
+    }
+
+    /**
+     *
+     * @param int $week The week of timetable
+     */
+    public function read_db($week) {
+        global $USER, $DB, $CFG;
+
+	$this->week = $week;
+	$sql = "$this->type = '$this->name' and not (mid(week, $this->week, 1) = '0')";
+	if ($result = $DB->get_records_select('timetable_lesson',$sql)) {
+		foreach ($result as $lesson) {
+			$this->data[$lesson->day][$lesson->period][] = $lesson;
+			if ($this->periodmax < $lesson->period) $this->periodmax = $lesson->period;
+		}
+	}
+    }
+
+    /**
+     * Count the number of online users
+     *
+     * @return int
+     */
+    public function print_table($view) {
+	global $DB;
+	//var_dump($this->data[1]);
+	$numperiod = $period_max = get_config('timetable', 'numperiod');
+	if ($this->periodmax>$numperiod) $numperiod = $this->periodmax;
+	$table = new \html_table();
+	$table->attributes['class'] = 'minicalendar calendartable generaltable';
+	$table->head = array('','Mo','Di', 'Mi' , 'Do', 'Fr');
+	for ($i = 1; $i<=$numperiod; $i++) {
+		$tablerow = new \html_table_row();
+		$cell = new \html_table_cell($i);
+		$cell->style = 'font-weight: bold;';
+//		$cell->attributes['class'] = 'header';
+		$tablerow->cells[] = $cell;
+		for ($k = 1; $k <= 5; $k++) {
+			$flag = 0;
+			if (array_key_exists($i,$this->data[$k])) {
+				$content = "";
+				foreach ($this->data[$k][$i] as $lesson) {
+					if ($content) $content .= "<br>";
+					$content .= $lesson->{$view};
+					$flag += $lesson->flag;
+				}
+			} else {
+				$content = "-";
+			}
+			$cell = new \html_table_cell($content);
+			if ($flag) $cell->style = 'color: red;';
+			$tablerow->cells[] = $cell;
+		}
+		$table->data[] = $tablerow;
+	}
+	return \html_writer::table($table);
+    }
+
+}
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..cd8c1fb
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,18 @@
+{
+    "name": "dannecker/moodle-block_timetable",
+    "description": "A block template for Moodle based on http://docs.moodle.org/dev/Blocks",
+    "license": "GPLv3",
+    "authors": [
+        {
+            "name": "Raphael Dannecker",
+            "email": "raphael.dannecker@steinbeisschule-reutlingen.de"
+        }
+    ],
+    "type": "moodle-block",
+    "require": {
+      "composer/installers": "~1.0"
+    },
+    "extra": {
+      "installer-name": "timetable"
+    }
+}
diff --git a/db/access.php b/db/access.php
new file mode 100644
index 0000000..2f11c15
--- /dev/null
+++ b/db/access.php
@@ -0,0 +1,51 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Newblock block caps.
+ *
+ * @package   block_timetable
+ * @copyright Daniel Neis <danielneis@gmail.com>
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$capabilities = array(
+
+    'block/timetable:myaddinstance' => array(
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_SYSTEM,
+        'archetypes' => array(
+            'user' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/my:manageblocks'
+    ),
+
+    'block/timetable:addinstance' => array(
+        'riskbitmask' => RISK_SPAM | RISK_XSS,
+
+        'captype' => 'write',
+        'contextlevel' => CONTEXT_BLOCK,
+        'archetypes' => array(
+            'editingteacher' => CAP_ALLOW,
+            'manager' => CAP_ALLOW
+        ),
+
+        'clonepermissionsfrom' => 'moodle/site:manageblocks'
+    ),
+);
diff --git a/db/install.xml b/db/install.xml
new file mode 100644
index 0000000..070c946
--- /dev/null
+++ b/db/install.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<XMLDB PATH="blocks/timetable/db" VERSION="20200624" COMMENT="XMLDB file for Moodle blocks/timetable"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
+>
+  <TABLES>
+    <TABLE NAME="block_timetable" COMMENT="Default comment for block_timetable, please edit me">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
+      </KEYS>
+    </TABLE>
+    <TABLE NAME="timetable_lesson" COMMENT="lessons">
+      <FIELDS>
+        <FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
+        <FIELD NAME="teacher" TYPE="char" LENGTH="20" NOTNULL="false" SEQUENCE="false" COMMENT="Teachers name"/>
+        <FIELD NAME="day" TYPE="int" LENGTH="2" NOTNULL="false" SEQUENCE="false" COMMENT="day of week"/>
+        <FIELD NAME="period" TYPE="int" LENGTH="2" NOTNULL="false" SEQUENCE="false" COMMENT="period"/>
+        <FIELD NAME="subject" TYPE="char" LENGTH="20" NOTNULL="false" SEQUENCE="false" COMMENT="subject"/>
+        <FIELD NAME="room" TYPE="char" LENGTH="20" NOTNULL="false" SEQUENCE="false" COMMENT="room"/>
+        <FIELD NAME="lessonid" TYPE="int" LENGTH="7" NOTNULL="false" SEQUENCE="false"/>
+        <FIELD NAME="flag" TYPE="int" LENGTH="7" NOTNULL="false" SEQUENCE="false" COMMENT="internal untis flag"/>
+        <FIELD NAME="class" TYPE="char" LENGTH="20" NOTNULL="false" SEQUENCE="false" COMMENT="name of class"/>
+        <FIELD NAME="week" TYPE="char" LENGTH="53" NOTNULL="false" SEQUENCE="false" COMMENT="week of schoolyear"/>
+        <FIELD NAME="unknown" TYPE="int" LENGTH="7" NOTNULL="false" SEQUENCE="false" COMMENT="undocumented field in untis txt-export"/>
+      </FIELDS>
+      <KEYS>
+        <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
+      </KEYS>
+    </TABLE>
+  </TABLES>
+</XMLDB>
diff --git a/db/tasks.php b/db/tasks.php
new file mode 100644
index 0000000..f77f3a9
--- /dev/null
+++ b/db/tasks.php
@@ -0,0 +1,16 @@
+<?php
+
+defined('MOODLE_INTERNAL') || die();
+
+$tasks = [
+    [
+        'classname' => '\block_timetable\task\import_data',
+        'blocking' => 0,
+	'minute' => '*/10',
+        'hour' => '*',
+        'day' => '*',
+        'month' => '*',
+        'dayofweek' => '*',
+    ],
+];
+
diff --git a/db/upgrade.php b/db/upgrade.php
new file mode 100644
index 0000000..81f331a
--- /dev/null
+++ b/db/upgrade.php
@@ -0,0 +1,60 @@
+<?php
+ 
+function xmldb_block_timetable_upgrade($oldversion) {
+    global $CFG;
+     
+    $result = TRUE;
+
+    global $DB;
+    $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes.
+
+    if ($oldversion < 2020062400) {
+
+        // Define table block_timetable to be created.
+        $table = new xmldb_table('block_timetable');
+
+        // Adding fields to table block_timetable.
+        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+
+        // Adding keys to table block_timetable.
+        $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
+
+        // Conditionally launch create table for block_timetable.
+        if (!$dbman->table_exists($table)) {
+            $dbman->create_table($table);
+        }
+        
+        // Define table timetable_lesson to be created.
+        $table = new xmldb_table('timetable_lesson');
+
+        // Adding fields to table timetable_lesson.
+        $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+        $table->add_field('teacher', XMLDB_TYPE_CHAR, '20', null, null, null, null);
+        $table->add_field('day', XMLDB_TYPE_INTEGER, '2', null, null, null, null);
+        $table->add_field('period', XMLDB_TYPE_INTEGER, '2', null, null, null, null);
+        $table->add_field('subject', XMLDB_TYPE_CHAR, '20', null, null, null, null);
+        $table->add_field('room', XMLDB_TYPE_CHAR, '20', null, null, null, null);
+        $table->add_field('lessonid', XMLDB_TYPE_INTEGER, '7', null, null, null, null);
+        $table->add_field('flag', XMLDB_TYPE_INTEGER, '7', null, null, null, null);
+        $table->add_field('class', XMLDB_TYPE_CHAR, '20', null, null, null, null);
+        $table->add_field('week', XMLDB_TYPE_CHAR, '53', null, null, null, null);
+        $table->add_field('unknown', XMLDB_TYPE_INTEGER, '7', null, null, null, null);
+
+        // Adding keys to table timetable_lesson.
+        $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
+
+        // Conditionally launch create table for timetable_lesson.
+        if (!$dbman->table_exists($table)) {
+            $dbman->create_table($table);
+        }
+
+        // Timetable savepoint reached.
+        upgrade_block_savepoint(true, 2020062400, 'timetable');
+        
+        
+    }
+
+	     
+    return $result;
+}
+?>
diff --git a/edit_form.php b/edit_form.php
new file mode 100644
index 0000000..e76fc01
--- /dev/null
+++ b/edit_form.php
@@ -0,0 +1,16 @@
+<?php
+
+class block_timetable_edit_form extends block_edit_form {
+
+    protected function specific_definition($mform) {
+
+        // Section header title according to language file.
+        $mform->addElement('header', 'configheader', get_string('blocksettings', 'block'));
+
+        // A sample string variable with a default value.
+        $mform->addElement('text', 'config_text', get_string('blockstring', 'block_timetable'));
+        $mform->setDefault('config_text', 'default value');
+        $mform->setType('config_text', PARAM_TEXT);        
+
+    }
+}
diff --git a/lang/de/block_timetable.php b/lang/de/block_timetable.php
new file mode 100644
index 0000000..36c9b7b
--- /dev/null
+++ b/lang/de/block_timetable.php
@@ -0,0 +1,33 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Strings for component 'block_timetable', language 'en'
+ *
+ * @package   block_timetable
+ * @copyright Daniel Neis <danielneis@gmail.com>
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+$string['blockstring'] = 'Block string';
+$string['descconfig'] = 'Description of the config section';
+$string['descfoo'] = 'Config description';
+$string['headerconfig'] = 'Config section header';
+$string['labelfoo'] = 'Config label';
+$string['timetable:addinstance'] = 'Add a timetable block';
+$string['timetable:myaddinstance'] = 'Add a timetable block to my moodle';
+$string['pluginname'] = 'Stundenplan';
diff --git a/lang/en/block_timetable.php b/lang/en/block_timetable.php
new file mode 100644
index 0000000..4af5280
--- /dev/null
+++ b/lang/en/block_timetable.php
@@ -0,0 +1,38 @@
+<?php
+
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Strings for component 'block_timetable', language 'en'
+ *
+ * @package   block_timetable
+ * @copyright Daniel Neis <danielneis@gmail.com>
+ * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+$string['blockstring'] = 'Block string';
+$string['descconfig'] = 'Description of the config section';
+$string['descfoo'] = 'Config description';
+$string['headerconfig'] = 'Config section header';
+$string['labelfoo'] = 'Config label';
+$string['timetable:addinstance'] = 'Add a timetable block';
+$string['timetable:myaddinstance'] = 'Add a timetable block to my moodle';
+$string['pluginname'] = 'Timetable';
+$string['import_data'] = 'import_data';
+$string['labelfnamelesson'] = 'import file';
+$string['descfnamelesson'] = 'Absolute path and Filename of untis import file lesson.txt';
+$string['labelnumperiod'] = 'max period';
+$string['descnumperiod'] = 'max period per day';
diff --git a/settings.php b/settings.php
new file mode 100644
index 0000000..f859317
--- /dev/null
+++ b/settings.php
@@ -0,0 +1,45 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Newblock block caps.
+ *
+ * @package    block_timetable
+ * @copyright  Daniel Neis <danielneis@gmail.com>
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+/*
+$settings->add(new admin_setting_heading('sampleheader',
+                                         get_string('headerconfig', 'block_timetable'),
+                                         get_string('descconfig', 'block_timetable')));
+
+$settings->add(new admin_setting_configcheckbox('timetable/foo',
+                                                get_string('labelfoo', 'block_timetable'),
+                                                get_string('descfoo', 'block_timetable'),
+						'0'));
+ */
+
+$settings->add(new admin_setting_configtext('timetable/fnamelesson',
+                                                get_string('labelfnamelesson', 'block_timetable'),
+						get_string('descfnamelesson', 'block_timetable'),
+						''));
+
+$settings->add(new admin_setting_configtext('timetable/numperiod',
+                                                get_string('labelnumperiod', 'block_timetable'),
+						get_string('descnumperiod', 'block_timetable'),
+						12, PARAM_INT));
diff --git a/version.php b/version.php
new file mode 100644
index 0000000..7a5b1b7
--- /dev/null
+++ b/version.php
@@ -0,0 +1,29 @@
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Version details
+ *
+ * @package    block_timetable
+ * @copyright  1999 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version   = 2020062504;        // The current plugin version (Date: YYYYMMDDXX)
+$plugin->requires  = 2012112900;        // Requires this Moodle version
+$plugin->component = 'block_timetable'; // Full name of the plugin (used for diagnostics)