mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-18 15:32:17 +00:00
Consolidate FHCApi childs
This commit is contained in:
@@ -31,7 +31,7 @@ class Config extends FHCAPI_Controller
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// TODO(chris): access!
|
||||
// TODO(chris): permissions
|
||||
parent::__construct([
|
||||
'student' => self::PERM_LOGGED,
|
||||
'students' => self::PERM_LOGGED
|
||||
|
||||
@@ -31,10 +31,9 @@ class Filter extends FHCAPI_Controller
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// TODO(chris): permissions
|
||||
parent::__construct([
|
||||
'getStg' => 'student/stammdaten:r',#self::PERM_LOGGED,
|
||||
'setStg' => 'student/stammdaten:r'#self::PERM_LOGGED
|
||||
'getStg' => self::PERM_LOGGED,
|
||||
'setStg' => self::PERM_LOGGED
|
||||
]);
|
||||
|
||||
// Load models
|
||||
@@ -53,10 +52,7 @@ class Filter extends FHCAPI_Controller
|
||||
{
|
||||
$result = $this->VariableModel->getVariables(getAuthUID(), ['kontofilterstg']);
|
||||
|
||||
#$data = $this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$data = $result->retval;
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data['kontofilterstg'] == 'true');
|
||||
}
|
||||
@@ -81,9 +77,7 @@ class Filter extends FHCAPI_Controller
|
||||
|
||||
$result = $this->VariableModel->setVariable(getAuthUID(), 'kontofilterstg', $studiengang_kz ? 'true' : 'false');
|
||||
|
||||
#$this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess(true);
|
||||
}
|
||||
|
||||
@@ -33,10 +33,9 @@ class Konto extends FHCAPI_Controller
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// TODO(chris): permissions
|
||||
parent::__construct([
|
||||
'get' => 'student/stammdaten:r',
|
||||
'getBuchungstypen' => 'student/stammdaten:r', // alle?
|
||||
'getBuchungstypen' => self::PERM_LOGGED,
|
||||
'checkDoubles' => ['admin:r', 'assistenz:r'],
|
||||
'insert' => ['admin:w', 'assistenz:w'],
|
||||
'counter' => ['admin:w', 'assistenz:w'],
|
||||
@@ -82,10 +81,7 @@ class Konto extends FHCAPI_Controller
|
||||
$result = $this->KontoModel->getAlleBuchungen($person_id, $studiengang_kz);
|
||||
}
|
||||
|
||||
#$result = $this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$result = $result->retval;
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
// sort into tree
|
||||
$childs = [];
|
||||
@@ -122,10 +118,7 @@ class Konto extends FHCAPI_Controller
|
||||
|
||||
$result = $this->BuchungstypModel->load();
|
||||
|
||||
#$data = $this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$data = $result->retval;
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
@@ -163,10 +156,7 @@ class Konto extends FHCAPI_Controller
|
||||
|
||||
$result = $this->KontoModel->checkDoubleBuchung($person_ids, $this->input->post('studiensemester_kurzbz'), $buchungstypen[$buchung]);
|
||||
|
||||
#$result = $this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$result = $result->retval;
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if (!$result)
|
||||
$this->terminateWithSuccess(false);
|
||||
@@ -441,9 +431,7 @@ class Konto extends FHCAPI_Controller
|
||||
|
||||
$result = $this->KontoModel->update($id, $data);
|
||||
|
||||
#$this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
$result = null;
|
||||
// TODO(chris): get as tree?
|
||||
@@ -475,15 +463,13 @@ class Konto extends FHCAPI_Controller
|
||||
$buchungsnr = $this->input->post('buchungsnr');
|
||||
|
||||
$result = $this->KontoModel->load($buchungsnr);
|
||||
#$result = $this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$result = $result->retval;
|
||||
|
||||
$result = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if (!$result)
|
||||
$this->terminateWithError($this->p->t('konto', 'error_missing', [
|
||||
'buchungsnr' => $buchungsnr
|
||||
]), self::ERROR_TYPE_GENERAL);
|
||||
]));
|
||||
|
||||
$_POST['studiengang_kz'] = current($result)->studiengang_kz;
|
||||
|
||||
@@ -500,8 +486,8 @@ class Konto extends FHCAPI_Controller
|
||||
$result = $this->KontoModel->delete($buchungsnr);
|
||||
if (isError($result)) {
|
||||
if (getCode($result) != 42)
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$this->terminateWithError($this->p->t('konto', 'error_delete_level'), self::ERROR_TYPE_GENERAL);
|
||||
$this->terminateWithError(getError($result));
|
||||
$this->terminateWithError($this->p->t('konto', 'error_delete_level'));
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess();
|
||||
|
||||
@@ -27,10 +27,9 @@ class Lists extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// TODO(chris): permissions
|
||||
parent::__construct([
|
||||
'getStudiensemester' => ['admin:r', 'assistenz:r', 'student/stammdaten:r'], // alle?
|
||||
'getStgs' => ['admin:r', 'assistenz:r', 'student/stammdaten:r'] // alle?
|
||||
'getStudiensemester' => self::PERM_LOGGED,
|
||||
'getStgs' => self::PERM_LOGGED
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -42,10 +41,7 @@ class Lists extends FHCAPI_Controller
|
||||
|
||||
$result = $this->StudiensemesterModel->load();
|
||||
|
||||
#$data = $this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$data = $result->retval;
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
@@ -62,10 +58,7 @@ class Lists extends FHCAPI_Controller
|
||||
|
||||
$result = $this->StudiengangModel->load();
|
||||
|
||||
#$data = $this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$data = $result->retval;
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
@@ -100,10 +100,7 @@ class Student extends FHCAPI_Controller
|
||||
|
||||
$result = $this->PrestudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
|
||||
|
||||
#$student = $this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$student = $result->retval;
|
||||
$student = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
if (!$student)
|
||||
return show_404();
|
||||
@@ -136,10 +133,7 @@ class Student extends FHCAPI_Controller
|
||||
|
||||
$result = $this->udflib->getCiValidations($this->PersonModel, $this->input->post());
|
||||
|
||||
#$fieldValidations = $this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result));
|
||||
$fieldvalidations = $result->retval;
|
||||
$fieldValidations = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->form_validation->set_rules($fieldvalidations);
|
||||
|
||||
@@ -148,19 +142,13 @@ class Student extends FHCAPI_Controller
|
||||
|
||||
$result = $this->StudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
|
||||
|
||||
#$student = $this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$student = $result->retval;
|
||||
$student = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$uid = $student ? current($student)->student_uid : null;
|
||||
|
||||
$result = $this->PrestudentModel->loadWhere(['prestudent_id' => $prestudent_id]);
|
||||
|
||||
#$person = $this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result));
|
||||
$person = $result->retval;
|
||||
$person = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$person_id = $person ? current($person)->person_id : null;
|
||||
|
||||
@@ -201,10 +189,7 @@ class Student extends FHCAPI_Controller
|
||||
// add UDFs
|
||||
$result = $this->udflib->getDefinitionForModel($this->PersonModel);
|
||||
|
||||
#$definitions = $this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$definitions = $result->retval;
|
||||
$definitions = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
foreach ($definitions as $def)
|
||||
$array_allowed_props_person[] = $def['name'];
|
||||
@@ -242,9 +227,7 @@ class Student extends FHCAPI_Controller
|
||||
'studiensemester_kurzbz' => $studiensemester_kurzbz,
|
||||
'student_uid' => $uid
|
||||
], $update_lehrverband);
|
||||
#$this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
|
||||
if (count($update_person)) {
|
||||
@@ -252,9 +235,7 @@ class Student extends FHCAPI_Controller
|
||||
$person_id,
|
||||
$update_person
|
||||
);
|
||||
#$this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
|
||||
|
||||
@@ -263,9 +244,7 @@ class Student extends FHCAPI_Controller
|
||||
[$uid],
|
||||
$update_student
|
||||
);
|
||||
#$this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess(array_fill_keys(array_merge(
|
||||
@@ -308,10 +287,7 @@ class Student extends FHCAPI_Controller
|
||||
|
||||
$result = $this->PersonModel->load();
|
||||
|
||||
#$data = $this->getDataOrTerminateWithError($result);
|
||||
if (isError($result))
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
$data = $result->retval;
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
@@ -413,9 +389,7 @@ class Student extends FHCAPI_Controller
|
||||
$data['staatsbuergerschaft'] = $this->input->post('staatsbuergerschaft');
|
||||
|
||||
$result = $this->PersonModel->insert($data);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$person_id = getData($result);
|
||||
$person_id = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
|
||||
// Addresse anlegen
|
||||
@@ -438,17 +412,15 @@ class Student extends FHCAPI_Controller
|
||||
$result = $this->AdresseModel->loadWhere([
|
||||
'person_id' => $person_id
|
||||
]);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (hasData($result)) {
|
||||
$address = current(getData($result));
|
||||
$address = $this->getDataOrTerminateWithError($result);
|
||||
if ($address) {
|
||||
$address = current($address);
|
||||
|
||||
$data['updateamum'] = date('c');
|
||||
$data['updatevon'] = getAuthUID();
|
||||
|
||||
$result = $this->AdresseModel->update($address->adresse_id, $data);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
} else {
|
||||
//Wenn keine Adrese vorhanden ist dann eine neue Anlegen
|
||||
$anlegen = 1;
|
||||
@@ -463,8 +435,7 @@ class Student extends FHCAPI_Controller
|
||||
$data['heimatadresse'] = !$this->input->post('person_id');
|
||||
|
||||
$result = $this->AdresseModel->insert($data);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,8 +459,7 @@ class Student extends FHCAPI_Controller
|
||||
'insertvon' => getAuthUID()
|
||||
];
|
||||
$result = $this->KontaktModel->insert($data);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -517,10 +487,9 @@ class Student extends FHCAPI_Controller
|
||||
$result = $this->PrestudentModel->loadWhere([
|
||||
'person_id' => $person_id
|
||||
]);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
if (hasData($result)) {
|
||||
$prestudent = current(getData($result));
|
||||
$prestudent = $this->getDataOrTerminateWithError($result);
|
||||
if ($prestudent) {
|
||||
$prestudent = current($prestudent);
|
||||
if ($prestudent->zgv_code) {
|
||||
$data['zgv_code'] = $prestudent->zgv_code;
|
||||
$data['zgvort'] = $prestudent->zgvort;
|
||||
@@ -533,9 +502,7 @@ class Student extends FHCAPI_Controller
|
||||
}
|
||||
// Prestudent speichern
|
||||
$result = $this->PrestudentModel->insert($data);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$prestudent_id = getData($result);
|
||||
$prestudent_id = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
// Prestudent Rolle Anlegen
|
||||
$data = [
|
||||
@@ -550,8 +517,7 @@ class Student extends FHCAPI_Controller
|
||||
'insertvon' => getAuthUID()
|
||||
];
|
||||
$result = $this->PrestudentstatusModel->insert($data);
|
||||
if (isError($result))
|
||||
return $result;
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
if ($incoming) {
|
||||
// TODO(chris): IMPLEMENT!
|
||||
@@ -569,7 +535,7 @@ class Student extends FHCAPI_Controller
|
||||
return $result;
|
||||
}*/
|
||||
|
||||
return success(true);
|
||||
$this->terminateWithSuccess(true);
|
||||
}
|
||||
|
||||
public function requiredIfNotPersonId($value)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright (C) 2022 fhcomplete.org
|
||||
* 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
|
||||
|
||||
Reference in New Issue
Block a user