From e642b6702c90a776e3281b6de965eb5615d32015 Mon Sep 17 00:00:00 2001 From: L_DA Date: Sun, 13 Sep 2020 21:07:32 +0200 Subject: [PATCH] CSS und Templates --- classes/timetable.php | 4 ++- externallib.php | 25 +++++++++++-- templates/searchform.mustache | 4 +-- templates/searchresult.mustache | 20 +++++++---- templates/timetable.mustache | 64 ++++++++++++++++++++++++--------- version.php | 2 +- 6 files changed, 90 insertions(+), 29 deletions(-) diff --git a/classes/timetable.php b/classes/timetable.php index 119dd4f..67598e8 100755 --- a/classes/timetable.php +++ b/classes/timetable.php @@ -266,10 +266,12 @@ class timetable { $mylesson['flag'] = ""; if ($lesson->flag) $mylesson['flag'] = $lesson->flag; + /* if ($this->type == 'class') $mylesson['class'] = ""; if ($this->type == 'teacher') $mylesson['teacher'] = ""; if ($this->type == 'room') $mylesson['room'] = ""; - $days[$day]['lessons'][] = $mylesson; + */ + if ($lesson->week[$this->week-1] != '0') $days[$day]['lessons'][] = $mylesson; /* - für diese Woche wurden keine Daten ausgegeben 0 in dieser Woche findet der Unterricht nicht statt diff --git a/externallib.php b/externallib.php index e65d54f..a80dc9f 100644 --- a/externallib.php +++ b/externallib.php @@ -57,6 +57,7 @@ class mod_timetable_external extends external_api { throw new moodle_exception('cannotviewprofile'); } + $results = array(); //return $params['searchstring'] . $USER->firstname ; $classes = $DB->get_records_select('timetable_class', 'class like ? OR description like ? LIMIT 10', array ('%'.$params['searchstring'].'%', '%'.$params['searchstring'].'%')); @@ -142,18 +143,38 @@ class mod_timetable_external extends external_api { $context = get_context_instance(CONTEXT_USER, $USER->id); self::validate_context($context); + //$contextmodule = context_module::instance($cm->id); + $usercontext = context_user::instance($USER->id); + + //Capability checking //OPTIONAL but in most web service it should present - if (!has_capability('moodle/user:viewdetails', $context)) { - throw new moodle_exception('cannotviewprofile'); + if (!has_capability('mod/timetable:view_'.$params['type'], $usercontext)) { + if (!(($params['type'] == 'class') && has_capability('mod/timetable:view_own_class', $usercontext) && ($params['name'] == str_replace('_','/',$USER->department)))) + throw new \moodle_exception('cannotviewtimetable'.$params['type']); } + /* + if ($USER->department == "Lehrer" || $USER->department == "Lehrer_fvs") { + + } elseif (($params['type'] == 'class') && ($params['name'] == str_replace('_','/',$USER->department))) { + + } else { + throw new \moodle_exeption('Forbidden'); + } + */ + + //echo "Type: ".$params['type']."\n"; //echo "Name: ".$params['name']."\n"; //echo "Week: ".$params['week']."\n"; if(!($params['week'])) { $today = new \DateTime(); $params['week'] = $today->format("W"); + $dayofweek = $today->format('w'); + if ($dayofweek > 5 + get_config('timetable', 'saturday')) { + $params['week']++; + } } $ttable = new \mod_timetable\timetable($params['type'],$params['name']); diff --git a/templates/searchform.mustache b/templates/searchform.mustache index e072ca7..73d1523 100644 --- a/templates/searchform.mustache +++ b/templates/searchform.mustache @@ -1,7 +1,7 @@ -