diff --git a/application/controllers/api/frontend/v1/Benutzer.php b/application/controllers/api/frontend/v1/Benutzer.php new file mode 100644 index 000000000..27e83eee3 --- /dev/null +++ b/application/controllers/api/frontend/v1/Benutzer.php @@ -0,0 +1,47 @@ +. + */ + +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); + } +} + diff --git a/public/js/api/factory/benutzer.js b/public/js/api/factory/benutzer.js new file mode 100644 index 000000000..c653154c9 --- /dev/null +++ b/public/js/api/factory/benutzer.js @@ -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 . + */ + +export default { + getUserData(uid = null) { + return { + method: 'get', + url: '/api/frontend/v1/Benutzer/getUserData', + params: { + uid + } + }; + }, +}; \ No newline at end of file diff --git a/public/js/components/Cis/LvPlan/MyLvPlan.js b/public/js/components/Cis/LvPlan/MyLvPlan.js index e88252092..6b8158804 100644 --- a/public/js/components/Cis/LvPlan/MyLvPlan.js +++ b/public/js/components/Cis/LvPlan/MyLvPlan.js @@ -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 diff --git a/public/js/components/Cis/LvPlan/OtherLvPlan.js b/public/js/components/Cis/LvPlan/OtherLvPlan.js index 51e32f1a7..8e39981ac 100644 --- a/public/js/components/Cis/LvPlan/OtherLvPlan.js +++ b/public/js/components/Cis/LvPlan/OtherLvPlan.js @@ -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