mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 12:19:28 +00:00
Merge branch 'master' into feature-52533_62055/Vertragsverwaltung_mit_CoreComponent_DetailHeader
This commit is contained in:
@@ -81,8 +81,11 @@ class FHCAPI_Controller extends Auth_Controller
|
||||
|
||||
// For JSON Requests (as opposed to multipart/form-data) get the $_POST variable from the input stream instead
|
||||
if ($this->input->get_request_header('Content-Type', true) == 'application/json')
|
||||
$_POST = json_decode($this->security->xss_clean($this->input->raw_input_stream), true);
|
||||
elseif (isset($_POST['_jsondata'])) {
|
||||
{
|
||||
$_POST = json_decode($this->input->raw_input_stream, true);
|
||||
}
|
||||
elseif (isset($_POST['_jsondata']))
|
||||
{
|
||||
$_POST = array_merge($_POST, json_decode($_POST['_jsondata'], true));
|
||||
unset($_POST['_jsondata']);
|
||||
}
|
||||
@@ -106,10 +109,15 @@ class FHCAPI_Controller extends Auth_Controller
|
||||
$error = [];
|
||||
|
||||
if (is_array($data)) {
|
||||
if ($type == self::ERROR_TYPE_VALIDATION)
|
||||
if ($type == self::ERROR_TYPE_VALIDATION) {
|
||||
$error['messages'] = $data;
|
||||
else
|
||||
} elseif (array_is_list($data)) {
|
||||
foreach ($data as $d)
|
||||
$this->addError($d, $type);
|
||||
return;
|
||||
} else {
|
||||
$error = $data;
|
||||
}
|
||||
} elseif (is_object($data)) {
|
||||
$error = (array)$data;
|
||||
} else {
|
||||
@@ -223,6 +231,39 @@ class FHCAPI_Controller extends Auth_Controller
|
||||
return $result->retval;
|
||||
}
|
||||
|
||||
protected function terminateWithFileOutput($contenttype, $content, $filename=null)
|
||||
{
|
||||
$this->clearOutputBuffering();
|
||||
$this->output->set_status_header(200)
|
||||
->set_content_type($contenttype)
|
||||
->set_header('Expires: 0')
|
||||
->set_header('Cache-Control: no-store, no-cache, must-revalidate')
|
||||
->set_header('Pragma: public')
|
||||
->set_header('Content-Length: ' . strlen($content));
|
||||
|
||||
if($filename)
|
||||
{
|
||||
$cleanedfilename = preg_replace('/[^a-zA-Z0-9\-_.]/', '_', $filename);
|
||||
$this->output->set_header('Content-Disposition: attachment; filename="'
|
||||
. $cleanedfilename . '"');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->output->set_header('Content-Disposition: inline');
|
||||
}
|
||||
|
||||
$this->output->set_output($content)
|
||||
->_display();
|
||||
exit();
|
||||
}
|
||||
|
||||
private function clearOutputBuffering()
|
||||
{
|
||||
while(ob_get_level() > 0)
|
||||
{
|
||||
ob_end_clean();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Security
|
||||
|
||||
@@ -21,6 +21,7 @@ abstract class Notiz_Controller extends FHCAPI_Controller
|
||||
'loadDokumente' => self::DEFAULT_PERMISSION_R,
|
||||
'getMitarbeiter' => self::DEFAULT_PERMISSION_R,
|
||||
'isBerechtigt' => self::DEFAULT_PERMISSION_R,
|
||||
'getCountNotes' => self::DEFAULT_PERMISSION_R,
|
||||
];
|
||||
|
||||
if(!is_array($permissions))
|
||||
@@ -459,4 +460,20 @@ abstract class Notiz_Controller extends FHCAPI_Controller
|
||||
return $this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function getCountNotes($person_id)
|
||||
{
|
||||
$this->NotizzuordnungModel->addSelect('COUNT(*) AS anzahl', false);
|
||||
|
||||
$result = $this->NotizzuordnungModel->loadWhere(
|
||||
array('person_id' => $person_id)
|
||||
);
|
||||
|
||||
if (isError($result)) {
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$anzahl = current(getData($result));
|
||||
return $this->terminateWithSuccess($anzahl->anzahl ?: 0);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user