mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 12:19:28 +00:00
Bugfix: uft8 json & codequality
This commit is contained in:
@@ -10,7 +10,7 @@ class Prestudent extends FHCAPI_Controller
|
||||
{
|
||||
parent::__construct([
|
||||
'get' => ['admin:r', 'assistenz:r'],
|
||||
'updatePrestudent' => ['admin:w', 'assistenz:w'],
|
||||
'updatePrestudent' => ['admin:rw', 'assistenz:rw'],
|
||||
'getHistoryPrestudents' => ['admin:r', 'assistenz:r'],
|
||||
'getBezeichnungZGV' => self::PERM_LOGGED,
|
||||
'getBezeichnungDZgv' => self::PERM_LOGGED,
|
||||
@@ -23,6 +23,11 @@ class Prestudent extends FHCAPI_Controller
|
||||
'getStudiengang' => self::PERM_LOGGED
|
||||
]);
|
||||
|
||||
if ($this->router->method == 'updatePrestudent') {
|
||||
$prestudent_id = current(array_slice($this->uri->rsegments, 2));
|
||||
$this->checkPermissionsForPrestudent($prestudent_id, ['admin:rw', 'assistenz:rw']);
|
||||
}
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
|
||||
@@ -52,30 +57,11 @@ class Prestudent extends FHCAPI_Controller
|
||||
|
||||
public function updatePrestudent($prestudent_id)
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
|
||||
//get Studiengang von prestudent_id
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
$result = $this->PrestudentModel->load([
|
||||
'prestudent_id'=> $prestudent_id,
|
||||
]);
|
||||
if(isError($result))
|
||||
{
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$result = current(getData($result));
|
||||
|
||||
$stg = $result->studiengang_kz;
|
||||
|
||||
if(!$this->permissionlib->isBerechtigt('admin', 'suid', $stg) && !$this->permissionlib->isBerechtigt('assistenz', 'suid', $stg))
|
||||
{
|
||||
return $this->terminateWithError($this->p->t('lehre','error_keineSchreibrechte'), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
//Form validation
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$this->form_validation->set_rules('priorisierung', 'Priorisierung', 'numeric', [
|
||||
'numeric' => $this->p->t('ui','error_fieldNotNumeric',['field' => 'Priorisierung'])
|
||||
'numeric' => $this->p->t('ui', 'error_fieldNotNumeric', ['field' => 'Priorisierung'])
|
||||
]);
|
||||
|
||||
if ($this->form_validation->run() == false)
|
||||
@@ -83,8 +69,6 @@ class Prestudent extends FHCAPI_Controller
|
||||
$this->terminateWithValidationErrors($this->form_validation->error_array());
|
||||
}
|
||||
|
||||
$deltaData = $_POST;
|
||||
|
||||
$uid = getAuthUID();
|
||||
|
||||
$array_allowed_props_prestudent = [
|
||||
@@ -124,7 +108,7 @@ class Prestudent extends FHCAPI_Controller
|
||||
$update_prestudent = array();
|
||||
foreach ($array_allowed_props_prestudent as $prop)
|
||||
{
|
||||
$val = isset($deltaData[$prop]) ? $deltaData[$prop] : null;
|
||||
$val = $this->input->post($prop);
|
||||
if ($val !== null || $prop == 'foerderrelevant') {
|
||||
$update_prestudent[$prop] = $val;
|
||||
}
|
||||
@@ -133,28 +117,17 @@ class Prestudent extends FHCAPI_Controller
|
||||
$update_prestudent['updateamum'] = date('c');
|
||||
$update_prestudent['updatevon'] = $uid;
|
||||
|
||||
//utf8-decode for special chars (eg tag der offenen Tür, FH-Führer)
|
||||
function utf8_decode_if_string($value)
|
||||
{
|
||||
if (is_string($value)) {
|
||||
return utf8_decode($value);
|
||||
} else {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
$update_prestudent_encoded = array_map('utf8_decode_if_string', $update_prestudent);
|
||||
|
||||
if (count($update_prestudent))
|
||||
{
|
||||
$result = $this->PrestudentModel->update(
|
||||
$prestudent_id,
|
||||
$update_prestudent_encoded
|
||||
$update_prestudent
|
||||
);
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
|
||||
return $this->terminateWithSuccess(true);
|
||||
}
|
||||
return $this->terminateWithSuccess(false);
|
||||
}
|
||||
|
||||
public function getHistoryPrestudents($person_id)
|
||||
|
||||
Reference in New Issue
Block a user