CSS und Templates

This commit is contained in:
L_DA 2020-09-13 21:07:32 +02:00
parent 45e9e4cf6a
commit e642b6702c
6 changed files with 90 additions and 29 deletions

View file

@ -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']);