fix(Plugin Moodle Event.php) adds the moodle calendar events integration through the Events instead of having a fixed dependency

This commit is contained in:
SimonGschnell
2025-02-27 12:06:43 +01:00
parent 9b68bfd336
commit e2b1dad776
4 changed files with 24 additions and 8 deletions
@@ -18,6 +18,8 @@
if (! defined('BASEPATH')) exit('No direct script access allowed');
use CI3_Events as Events;
class Stundenplan extends FHCAPI_Controller
{
@@ -28,6 +30,7 @@ class Stundenplan extends FHCAPI_Controller
{
parent::__construct([
'fetchMoodleEvents' => self::PERM_LOGGED,
'getRoomplan' => self::PERM_LOGGED,
'Stunden' => self::PERM_LOGGED,
'Reservierungen' => self::PERM_LOGGED,
@@ -57,6 +60,21 @@ class Stundenplan extends FHCAPI_Controller
//------------------------------------------------------------------------------------------------------------------
// Public methods
public function fetchMoodleEvents(){
$this->load->library('form_validation');
$this->form_validation->set_data($_GET);
$this->form_validation->set_rules('timestart',"timestart","required");
$this->form_validation->set_rules('timeend',"timeend","required");
if($this->form_validation->run() === FALSE) $this->terminateWithValidationErrors($this->form_validation->error_array());
$timestart = intval($this->input->get('timestart', TRUE));
$timeend = intval($this->input->get('timeend', TRUE));
Events::trigger('moodleCalendarEvents',
['timestart'=>$timestart,'timeend'=>$timeend, 'username'=>getAuthUID()]
);
$this->terminateWithSuccess(json_decode(ob_get_contents()));
}
//TODO: delete this function if we don't use the old calendar export endpoints anymore
public function studiensemesterDateInterval($date){
$this->load->model('organisation/Studiensemester_model','StudiensemesterModel');
+2 -4
View File
@@ -42,12 +42,10 @@ export default {
{}
);
},
getMoodleEventsByUserid(username, timestart, timeend) {
getMoodleEventsByUserid(timestart, timeend) {
return this.$fhcApi.get(
FHC_JS_DATA_STORAGE_OBJECT.app_root +
`addons/moodle/cis/get_events_by_userid.php`,
`/api/frontend/v1/Stundenplan/fetchMoodleEvents`,
{
username: username,
timestart: timestart,
timeend: timeend,
}
@@ -250,7 +250,7 @@ const Stundenplan = {
let date_start = Math.floor(new Date(start_date).getTime() / 1000);
let date_end = Math.floor(new Date(end_date).getTime() / 1000);
return this.$fhcApi.factory.stundenplan.getMoodleEventsByUserid('io23m005', date_start, date_end).then((response) => response.events).then(events => {
return this.$fhcApi.factory.stundenplan.getMoodleEventsByUserid(date_start, date_end).then((response) => response?.data?.events).then(events => {
let data =events.map(event =>{
const event_start_date = new Date(event.timestart);
const event_end_date = new Date(event.timeend);
@@ -170,7 +170,7 @@ export default {
let date_start = Math.floor(new Date(start_date).getTime() / 1000);
let date_end = Math.floor(new Date(end_date).getTime() / 1000);
return this.$fhcApi.factory.stundenplan.getMoodleEventsByUserid('io23m005', date_start, date_end).then((response) => response.events).then(events => {
return this.$fhcApi.factory.stundenplan.getMoodleEventsByUserid(date_start, date_end).then((response) => response?.data?.events).then(events => {
let data = events.map(event => {
const event_start_date = new Date(event.timestart);
const event_end_date = new Date(event.timeend);
@@ -230,7 +230,7 @@ export default {
<div v-if="event.type=='moodle'">
<div class="d-flex small w-100" >
<moodle-svg></moodle-svg>
<span class="flex-grow-1 text-center ">{{event.topic}}</span>
<span v-contrast class="flex-grow-1 text-center ">{{event.topic}}</span>
</div>
</div>
<span v-else class="small" >
@@ -250,7 +250,7 @@ export default {
<template v-if="evt.type=='moodle'">
<div class="d-flex align-items-center ">
<moodle-svg></moodle-svg>
<b class="flex-grow-1 text-center">{{evt.topic}}</b>
<b v-contrast class="flex-grow-1 text-center">{{evt.topic}}</b>
</div>
</template>
<template v-else>