mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-10-12 15:04:04 +00:00
97 lines
3.1 KiB
PHP
97 lines
3.1 KiB
PHP
<?php
|
|
/**
|
|
* Copyright (C) 2024 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 Studgang extends FHCAPI_Controller
|
|
{
|
|
|
|
/**
|
|
* Object initialization
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct([
|
|
'getStudiengangInfo'=> self::PERM_LOGGED,
|
|
'getDegreePrograms'=> self::PERM_LOGGED,
|
|
]);
|
|
|
|
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
|
|
$this->load->model('ressource/mitarbeiter_model', 'MitarbeiterModel');
|
|
|
|
// Loads phrases system
|
|
$this->loadPhrases([
|
|
'global'
|
|
]);
|
|
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
// Public methods
|
|
|
|
public function getDegreePrograms() {
|
|
$entitledDegreePrograms = $this->permissionlib->getSTG_isEntitledFor("basis/news");
|
|
if (!$entitledDegreePrograms) {
|
|
$this->terminateWithError("User is not entitled for any degree program");
|
|
}
|
|
|
|
$activeDegreePrograms = $this->StudiengangModel->getDegreePrograms();
|
|
$activeDegreePrograms= $this->getDataOrTerminateWithError($activeDegreePrograms);
|
|
|
|
$activeDegreePrograms = array_values(array_filter($activeDegreePrograms, function($degreeProgram) use ($entitledDegreePrograms) {
|
|
return in_array($degreeProgram->studiengang_kz, $entitledDegreePrograms);
|
|
}));
|
|
|
|
$this->terminateWithSuccess($activeDegreePrograms);
|
|
}
|
|
|
|
public function getStudiengangInfo(){
|
|
$studiengang_kz = $this->input->get('studiengang_kz', true);
|
|
$semester = $this->input->get('semester', true);
|
|
|
|
// without a Studiengang the info of the logged in Student is returned
|
|
if (!is_numeric($studiengang_kz))
|
|
{
|
|
$isMitarbeiter = $this->MitarbeiterModel->isMitarbeiter(getAuthUID());
|
|
$isMitarbeiter = $this->getDataOrTerminateWithError($isMitarbeiter);
|
|
if($isMitarbeiter) {
|
|
$this->terminateWithSuccess(null);
|
|
}
|
|
|
|
$studiengang_kz = null;
|
|
$semester = null;
|
|
}
|
|
else
|
|
{
|
|
$studiengang_kz = (int)$studiengang_kz;
|
|
$semester = is_numeric($semester) ? (int)$semester : null;
|
|
}
|
|
|
|
// fetches the Studiengang Information which is used next to the news
|
|
$studiengangInfo = $this->StudiengangModel->getStudiengangInfoForNews($studiengang_kz, $semester);
|
|
$studiengangInfo= $this->getDataOrTerminateWithError($studiengangInfo);
|
|
$this->terminateWithSuccess($studiengangInfo);
|
|
}
|
|
|
|
//------------------------------------------------------------------------------------------------------------------
|
|
// Private methods
|
|
|
|
|
|
|
|
}
|
|
|