mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-10-12 23:14:02 +00:00
filtering selectable semesters in range view depending on user age
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2026 fhcomplete.org
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Benutzer extends FHCAPI_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Object initialization
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getUserData' => self::PERM_LOGGED,
|
||||
]);
|
||||
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
public function getUserData()
|
||||
{
|
||||
$uid = $this->input->get("uid") ?? getAuthUID();
|
||||
$userResult = $this->BenutzerModel->load(["uid" => $uid]);
|
||||
$userData = $this->getDataOrTerminateWithError($userResult);
|
||||
$this->terminateWithSuccess($userData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Copyright (C) 2026 fhcomplete.org
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
export default {
|
||||
getUserData(uid = null) {
|
||||
return {
|
||||
method: 'get',
|
||||
url: '/api/frontend/v1/Benutzer/getUserData',
|
||||
params: {
|
||||
uid
|
||||
}
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -4,6 +4,7 @@ import ApiLvPlan from "../../../api/factory/lvPlan.js";
|
||||
import ApiAuthinfo from "../../../api/factory/authinfo.js";
|
||||
import ApiRoomPlan from "../../../api/factory/calendar/roomPlan.js";
|
||||
import ApiStudiensemester from "../../../api/factory/studiensemester.js";
|
||||
import ApiBenutzer from "../../../api/factory/benutzer.js";
|
||||
|
||||
export const DEFAULT_MODE_LVPLAN_DESKTOP = "Week";
|
||||
export const DEFAULT_MODE_LVPLAN_MOBILE = "List";
|
||||
@@ -220,6 +221,11 @@ export default {
|
||||
this.$refs.calendar.reset();
|
||||
},
|
||||
async fetchSemesters() {
|
||||
let userCreatedAt = null;
|
||||
const userResponse = await this.$api.call(ApiBenutzer.getUserData());
|
||||
if (userResponse.meta.status === "success" && userResponse.data[0].insertamum) {
|
||||
userCreatedAt = luxon.DateTime.fromFormat(userResponse.data[0].insertamum.split(" ")[0], "yy-MM-dd");
|
||||
}
|
||||
const semestersResponse = await this.$api.call(
|
||||
ApiStudiensemester.getAll(),
|
||||
);
|
||||
@@ -235,6 +241,11 @@ export default {
|
||||
description: semester.bezeichnung,
|
||||
};
|
||||
})
|
||||
.filter((semester) => {
|
||||
if (!userCreatedAt) return true;
|
||||
|
||||
return userCreatedAt.ts < semester.endDate.ts;
|
||||
})
|
||||
.sort((semesterA, semesterB) =>
|
||||
semesterA.startDate.ts > semesterB.startDate.ts
|
||||
? -1
|
||||
|
||||
@@ -6,6 +6,7 @@ import ApiLvPlan from "../.././../api/factory/lvPlan.js";
|
||||
import ApiOtherLvPlan from "../.././../api/factory/otherLvPlan.js";
|
||||
import ApiAuthinfo from "../../../api/factory/authinfo.js";
|
||||
import ApiStudiensemester from "../../../api/factory/studiensemester.js";
|
||||
import ApiBenutzer from "../../../api/factory/benutzer.js";
|
||||
|
||||
export const DEFAULT_MODE_LVPLAN_DESKTOP = "Week";
|
||||
export const DEFAULT_MODE_LVPLAN_MOBILE = "List";
|
||||
@@ -263,6 +264,19 @@ export default {
|
||||
);
|
||||
},
|
||||
async fetchSemesters() {
|
||||
let userCreatedAt = null;
|
||||
const userResponse = await this.$api.call(
|
||||
ApiBenutzer.getUserData(this.propsViewData.otherUid),
|
||||
);
|
||||
if (
|
||||
userResponse.meta.status === "success" &&
|
||||
userResponse.data[0].insertamum
|
||||
) {
|
||||
userCreatedAt = luxon.DateTime.fromFormat(
|
||||
userResponse.data[0].insertamum.split(" ")[0],
|
||||
"yy-MM-dd",
|
||||
);
|
||||
}
|
||||
const semestersResponse = await this.$api.call(
|
||||
ApiStudiensemester.getAll(),
|
||||
);
|
||||
@@ -278,6 +292,11 @@ export default {
|
||||
description: semester.bezeichnung,
|
||||
};
|
||||
})
|
||||
.filter((semester) => {
|
||||
if (!userCreatedAt) return true;
|
||||
|
||||
return userCreatedAt.ts < semester.endDate.ts;
|
||||
})
|
||||
.sort((semesterA, semesterB) =>
|
||||
semesterA.startDate.ts > semesterB.startDate.ts
|
||||
? -1
|
||||
|
||||
Reference in New Issue
Block a user