Compare commits

..

25 Commits

Author SHA1 Message Date
Paolo 92465fd943 Merge branch 'master' into feature-61599/DocumentExportLib_erweitern 2026-04-27 13:03:56 +02:00
Paolo 5df7358aff Merge branch 'master' into feature-61599/DocumentExportLib_erweitern 2026-03-24 10:51:09 +01:00
Paolo c70129cf37 Code cleaning OP#71539 2026-02-23 14:55:50 +01:00
Paolo 4b8f757a7c Merge branch 'master' into feature-61599/DocumentExportLib_erweitern 2026-02-23 12:26:37 +01:00
Alexei Karpenko e1bad61a27 api/frontend/Documents.php: removed addmeta debugging calls 2026-02-09 18:53:51 +01:00
Alexei Karpenko f4d8a396f5 document export bugfixes: getting content from db in Documents.php, correctly return data in Dokumente.php, passing temp folder in DocumentExportLib, path fix in DocumentLib, correct parameters in Archiv.php getByPersonId call, Archiv.js: check if array is returned, different controller for download (dokumente instead of akte) 2026-02-09 14:22:39 +01:00
Paolo 0b797cfdb1 Merge branch 'master' into feature-61599/DocumentExportLib_erweitern 2026-02-09 12:35:12 +01:00
Alexei Karpenko 7909edb402 fixed bug in FHC_Controller outputFile method: corrected filename header name 2026-02-03 17:32:38 +01:00
Paolo 7a7cda3488 Merge branch 'master' into feature-61599/DocumentExportLib_erweitern 2026-01-13 16:38:13 +01:00
Paolo 3f52b8c8d1 Merge branch 'master' into feature-61599/DocumentExportLib_erweitern 2025-10-21 15:04:48 +02:00
Paolo deaacc494d Fixed indentation 2025-10-01 11:05:41 +02:00
Paolo 21733d1e5e Merge branch 'master' into feature-61599/DocumentExportLib_erweitern 2025-10-01 09:39:40 +02:00
Paolo 28ef0b5892 Replaced global function uploadFile with the protected method FHC_Controller->uploadFile 2025-09-29 09:37:39 +02:00
Paolo 1657ae8291 - Removed global function uploadFile from application/helpers/hlp_common_helper.php
- Added new protected method uploadFile to application/core/FHC_Controller.php
- Replaced global function uploadFile with the protected method FHC_Controller->uploadFile
2025-09-29 09:32:21 +02:00
Paolo 517f39dc1f Removed unused parameter from the application/libraries/DmsLib.php constructor 2025-09-24 14:29:31 +02:00
Paolo b129bb659b - application/libraries/DocumentExportLib.php now makes use of the application/libraries/SignatureLib.php
- Fixex & improvements
2025-09-18 10:40:28 +02:00
Paolo d54ab06ad4 - Removed DocumentExportLib->showContent
- Adapted code to replace DocumentExportLib->showContent with DocumentExportLib->getContent + file download
- DocumentExportLib now makes use of the DocumentLib
2025-09-17 16:53:14 +02:00
Paolo 2dc341e048 Removed DMS_PATH from the file name in the DmsLib->getOutputFileInfo 2025-09-16 17:37:55 +02:00
Paolo 36f857428e - Fixed typos
- application/controllers/Cis/Pub.php bild method refactored
- Replaced AkteModel with AkteLib where possible
- application/core/FHC_Controller->outputFile added new features + improvements
- Added new public methods outputImageByContent and outputImageByFile to application/core/FHC_Controller
- Added new private method _outputImage to application/core/FHC_Controller
- AkteLib fixes
2025-09-16 17:12:59 +02:00
Paolo 909eb0bf57 Fixed AkteLib->_remove 2025-09-15 17:42:40 +02:00
Paolo 949fdfa5ca - DmsLib->download removed
- DmsLib->upload replaced by uploadFile
- Removed who parameter from DmsLib constructor
- Added insert by into DmsLib add and addLastVersion
- Removed commented code
- Replaced self with $this in the Anrechnung classes
- Added removeByPersonIdAndDmsId to AkteLib
2025-09-15 17:16:48 +02:00
Paolo 6edc8a127f Fixed application/libraries/DocumentExportLib.php to generate docs with DocsboxLib 2025-09-09 15:55:56 +02:00
Paolo eaacbcf7cc - Bugfix in application/controllers/Cis/Documents.php
- application/libraries/AkteLib.php->_get fixes
- b/application/libraries/DmsLib.php better handling when no DMS is found
2025-09-09 15:48:53 +02:00
Paolo 88cdd43b3e Fixed AkteLib 2025-09-09 14:28:36 +02:00
Paolo 2ee0c95467 - DmsLib:
- Removed deprecated methods from the DMSLib, these were the "problematic" types of methods:
		- Methods that would perform an upload/download of the file (should be performed by a controller)
		- Methods that were returning a base64 representation of the file (what if the file is a 1Gb?)
		- Methods that were performing operation on the akte (should be done in the AkteLib)
	- The first two types have been removed and added new utility method to read a file (wrapper of the DMSFSModel)
	- The last type of methods has been removed and same functionalities already exists in the AkteLib
	- Minor fixes
- AkteLib:
	- Added new methods to get an akte with relative content (even from the DMS) with different parameters (akte_id, person_id, dokument_kurzbz, signiert, stud_selfservice)
- AkteModel:
	- Removed the getArchiv method
- Replaced the usage of the AkteModel with the AkteLib as much as possible. AkteModel is used mainly to quickly check if an akte exists or not, otherwise the AkteLib is used for read/write operations
- Replaced the DmsLib usage with the AkteLib usage where the old deprecated DmsLib methods, that were working with the akte too, were used
2025-09-09 13:28:56 +02:00
280 changed files with 5151 additions and 22888 deletions
-9
View File
@@ -23,15 +23,6 @@ Events::on('loadRenderers', function ($renderers) {
);
});
Events::on('loadRenderers', function ($renderers) {
$fhc_core_renderers =& $renderers();
$fhc_core_renderers["slot_room"] = array(
'modalTitle' => APP_ROOT.'public/js/components/Cis/Renderer/Slot/roomModalTitle.js',
'modalContent' => APP_ROOT.'public/js/components/Cis/Renderer/Slot/roomModalContent.js',
'calendarEventStyles' => APP_ROOT.'public/css/Cis4/CoreCalendarEvents.css'
);
});
Events::on('loadRenderers', function ($renderers) {
$fhc_core_renderers =& $renderers();
$fhc_core_renderers["ferien"] = array(
-7
View File
@@ -170,13 +170,6 @@ $config['navigation_header'] = array(
'expand' => true,
'sort' => 51,
'requiredPermissions' => 'vertrag/mitarbeiter:r'
),
'studierendenverwaltung' => array(
'link' => site_url('studentenverwaltung'),
'description' => 'Studierendenverwaltung',
'expand' => true,
'sort' => 52,
'requiredPermissions' => ['admin:r', 'assistenz:r']
)
)
),
-6
View File
@@ -1,6 +0,0 @@
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
// 'entschuldigt' & 'noch nicht eingetragen' -> wirken sich nicht auf Antritte aus
$config['NOTEN_OHNE_ANTRITT'] = [9, 17]; // tbl_note pk
-4
View File
@@ -64,10 +64,6 @@ $route['api/v1/system/[S|s]prache/(:any)'] = 'api/v1/system/sprache2/$1';
$route['Cis/LvPlan/.*'] = 'Cis/LvPlan/index/$1';
$route['Cis/MyLvPlan/.*'] = 'Cis/MyLvPlan/index/$1';
$route['Cis/MyLv/.*'] = 'Cis/MyLv/index/$1';
$route['Cis/OtherLvPlan/.*'] = 'Cis/OtherLvPlan/index/$1';
//Route for LV Plan Stg/Semester/Verband/Gruppe
$route['Cis/StgOrgLvPlan/.*'] = 'Cis/StgOrgLvPlan/index/$1';
$route['Cis/Benotungstool/.*'] = 'Cis/Benotungstool/index/$1';
$route['Abgabetool/Assistenz'] = 'Cis/Abgabetool/Assistenz';
$route['Abgabetool/Assistenz/(:any)'] = 'Cis/Abgabetool/Assistenz/$1';
+1 -2
View File
@@ -22,9 +22,8 @@ unset($config['student']['searchfields']['email']);
unset($config['student']['searchfields']['tel']);
$config['student']['resultfields'] = [
"s.student_uid AS uid",
"s.matrikelnr AS personenkennzeichen",
"s.matrikelnr",
"p.person_id",
"p.matr_nr AS matrikelnummer",
"(p.vorname || ' ' || p.nachname) AS name",
"ARRAY[s.student_uid || '@' || '" . DOMAIN . "'] AS email",
"CASE
+7 -15
View File
@@ -133,21 +133,13 @@ $config['students_tab_order'] = [
$config['stv_prestudent_tags'] = [
'prioone' => ['readonly' => false],
'priotwo' => ['readonly' => false],
'priotwo' => ['readonly' => true],
'hinweis' => ['readonly' => false],
'hinweis_assistenz' => ['readonly' => false],
'hinweis_kf' => ['readonly' => false],
'hinweis_assistenz' => ['readonly' => true],
'hinweis_kf' => ['readonly' => true],
'hinweis_lehrende' => ['readonly' => false],
'hinweis_stg_kf' => ['readonly' => false],
'finished_stg' => ['readonly' => false],
'finished_kf' => ['readonly' => false],
'inwork_kf' => ['readonly' => false],
'dd_auto' => ['readonly' => true],
'wh_auto' => ['readonly' => true],
'prewh_auto' => ['readonly' => true],
'out_auto' => ['readonly' => true],
'zgv_auto' => ['readonly' => true],
'unterbrecher_auto' => ['readonly' => true],
'stbtr_erh_auto' => ['readonly' => true],
'jgv_auto' => ['readonly' => true],
'hinweis_stg_kf' => ['readonly' => true],
'finished_stg' => ['readonly' => true],
'finished_kf' => ['readonly' => true],
'inwork_kf' => ['readonly' => true],
];
+26 -5
View File
@@ -31,8 +31,12 @@ class Abgabetool extends Auth_Controller
{
// TODO: routing from index based on berechtigung?
$viewData = array(
'uid'=>getAuthUID(),
);
if(defined('CIS4') && CIS4) {
$this->load->view('CisRouterView/CisRouterView.php', ['route' => 'Abgabetool']);
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'Abgabetool']);
} else {
$this->load->view('Cis/Abgabetool.php', ['uid' => getAuthUID(), 'route' => 'Abgabetool']);
}
@@ -40,8 +44,12 @@ class Abgabetool extends Auth_Controller
public function Student($student_uid_prop = '')
{
$viewData = array(
'uid'=>getAuthUID(),
);
if(defined('CIS4') && CIS4) {
$this->load->view('CisRouterView/CisRouterView.php', ['route' => 'AbgabetoolStudent']);
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'AbgabetoolStudent']);
} else {
$this->load->view('Cis/Abgabetool.php', ['uid' => getAuthUID(), 'route' => 'AbgabetoolStudent', 'student_uid_prop' => $student_uid_prop]);
}
@@ -49,8 +57,12 @@ class Abgabetool extends Auth_Controller
public function Mitarbeiter()
{
$viewData = array(
'uid'=>getAuthUID(),
);
if(defined('CIS4') && CIS4) {
$this->load->view('CisRouterView/CisRouterView.php', ['route' => 'AbgabetoolMitarbeiter']);
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'AbgabetoolMitarbeiter']);
} else {
$this->load->view('Cis/Abgabetool.php', ['uid' => getAuthUID(), 'route' => 'AbgabetoolMitarbeiter']);
}
@@ -58,8 +70,13 @@ class Abgabetool extends Auth_Controller
public function Assistenz($stg_kz_prop = '')
{
$viewData = array(
'uid'=>getAuthUID(),
);
if(defined('CIS4') && CIS4) {
$this->load->view('CisRouterView/CisRouterView.php', ['route' => 'AbgabetoolAssistenz']);
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'AbgabetoolAssistenz']);
} else {
$this->load->view('Cis/Abgabetool.php', ['uid' => getAuthUID(), 'route' => 'AbgabetoolAssistenz', 'stg_kz_prop' => $stg_kz_prop]);
}
@@ -67,8 +84,12 @@ class Abgabetool extends Auth_Controller
public function Deadlines()
{
$viewData = array(
'uid'=>getAuthUID(),
);
if(defined('CIS4') && CIS4) {
$this->load->view('CisRouterView/CisRouterView.php', ['route' => 'DeadlinesOverview']);
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'DeadlinesOverview']);
} else {
$this->load->view('Cis/Abgabetool.php', ['uid' => getAuthUID(), 'route' => 'DeadlinesOverview']);
}
+1 -1
View File
@@ -40,7 +40,7 @@ class Auth extends FHC_Controller
if ($this->form_validation->run())
{
redirect($this->authlib->getLandingPage('/Cis4'));
redirect($this->authlib->getLandingPage('/CisVue/Dashboard'));
}
else
{
+10 -5
View File
@@ -20,8 +20,12 @@ class Documents extends Auth_Controller
'download' => [self::PERM_LOGGED]
]);
// Load models
$this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
// Load libraries
$this->load->library('AkteLib');
$this->loadPhrases([
'global',
'tools'
@@ -112,10 +116,12 @@ class Documents extends Auth_Controller
$selfservice = null;
if (!defined('CIS_DOKUMENTE_SELFSERVICE') || CIS_DOKUMENTE_SELFSERVICE) {
$this->load->model('crm/Akte_model', 'AkteModel');
$selfservice = [];
foreach ($person_ids as $person_id) {
$result = $this->AkteModel->getArchiv($person_id, null, true);
$result = $this->aktelib->getByPersonId(
$person_id,
true
);
if (isError($result))
return $this->load->view('errors/html/error_db.php', [
'heading' => 'Database Error',
@@ -147,14 +153,13 @@ class Documents extends Auth_Controller
if (!is_numeric($akte_id))
return show_404();
$this->load->model('crm/Akte_model', 'AkteModel');
$result = $this->AkteModel->load($akte_id);
$result = $this->aktelib->getByAkteId($akte_id);
if (isError($result))
return show_error(getError($result));
$akte = getData($result);
if (!$akte)
return show_404();
$akte = current($akte);
$akte = reset($akte);
$admin_access = false;
if ($uid !== null && $this->permissionlib->isBerechtigt('admin')) {
+7 -1
View File
@@ -28,6 +28,12 @@ class LvPlan extends Auth_Controller
*/
public function index()
{
$this->load->view('CisRouterView/CisRouterView.php', ['route' => 'LvPlan']);
$viewData = array(
'uid'=>getAuthUID(),
'timezone' => $this->config->item('timezone')
);
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'LvPlan']);
}
}
+6 -1
View File
@@ -26,6 +26,11 @@ class MyLv extends Auth_Controller
*/
public function index()
{
$this->load->view('CisRouterView/CisRouterView.php', ['route' => 'MyLv']);
$viewData = array(
);
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'MyLv']);
}
}
+8 -2
View File
@@ -27,7 +27,13 @@ class MyLvPlan extends Auth_Controller
* @return void
*/
public function index()
{
$this->load->view('CisRouterView/CisRouterView.php', ['route' => 'MyLvPlan']);
{
$viewData = array(
'uid'=>getAuthUID(),
'timezone' => $this->config->item('timezone')
);
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'MyLvPlan']);
}
}
@@ -1,34 +0,0 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
/**
*
*/
class OtherLvPlan extends Auth_Controller
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct([
'index' => ['basis/other_lv_plan:r']
]);
// Load Config
$this->load->config('calendar');
}
// -----------------------------------------------------------------------------------------------------------------
// Public methods
/**
* @return void
*/
public function index()
{
$this->load->view('CisRouterView/CisRouterView.php', ['route' => 'OtherLvPlan']);
}
}
+39 -19
View File
@@ -55,7 +55,15 @@ class Profil extends Auth_Controller
*/
public function index()
{
$this->load->view('CisRouterView/CisRouterView.php', ['route' => 'profilIndex']);
$this->load->library('ProfilLib');
$profil_data = $this->profillib->getView(getAuthUID());
$profil_data = hasData($profil_data) ? getData($profil_data) : null;
$viewData = array(
'editable'=>true,
'profil_data' => $profil_data,
);
$this->load->view('CisRouterView/CisRouterView.php',['viewData' => $viewData, 'route' => 'profilIndex']);
}
/**
@@ -65,13 +73,23 @@ class Profil extends Auth_Controller
*/
public function View($uid)
{
$this->load->view('CisRouterView/CisRouterView.php', ['route' => 'profilViewUid']);
$this->load->library('ProfilLib');
$profil_data = $this->profillib->getView($uid);
$profil_data = hasData($profil_data) ? getData($profil_data) : null;
$viewData = array (
'uid' => $uid,
'profil_data'=>$profil_data,
);
if($uid == getAuthUID()){
$viewData['editable'] = true;
}
$this->load->view('CisRouterView/CisRouterView.php',['viewData' => $viewData, 'route' => 'profilViewUid']);
}
/**
* checks whether a specific userID is a student or not (foreword declaration of the function isStudent in Student_model.php)
* checks whether a specific userID is a mitarbeiter or not (foreword declaration of the function isMitarbeiter in Mitarbeiter_model.php)
* @access public
* @param $uid the userID used to check if it is a student
* @param $uid the userID used to check if it is a mitarbeiter
* @return boolean
*/
public function isStudent($uid)
@@ -101,7 +119,7 @@ class Profil extends Auth_Controller
}
/**
* gets the adressen that are marked as zustell from the currently logged in user
* gets the adressen that are marked as zustell from the currenlty logged in user
* @access public
* @return array a list of adresse_id's
*/
@@ -244,23 +262,23 @@ class Profil extends Auth_Controller
$this->GemeindeModel->addDistinct();
$this->GemeindeModel->addSelect(["name"]);
if ($nation == "A") {
if (isset($zip) && $zip > 999 && $zip < 32000) {
if (isset($zip) && $zip > 999 && $zip < 32000) {
$gemeinde_res = $this->GemeindeModel->loadWhere(['plz' => $zip]);
if (isError($gemeinde_res)) {
show_error("error while trying to query bis.tbl_gemeinde");
$gemeinde_res = $this->GemeindeModel->loadWhere(['plz' => $zip]);
if (isError($gemeinde_res)) {
show_error("error while trying to query bis.tbl_gemeinde");
}
$gemeinde_res = hasData($gemeinde_res) ? getData($gemeinde_res) : null;
$gemeinde_res = array_map(function ($obj) {
return $obj->name;
}, $gemeinde_res);
echo json_encode($gemeinde_res);
} else {
echo json_encode(error("ortschaftskennziffer code was not valid"));
}
$gemeinde_res = hasData($gemeinde_res) ? getData($gemeinde_res) : null;
$gemeinde_res = array_map(function ($obj) {
return $obj->name;
}, $gemeinde_res);
echo json_encode($gemeinde_res);
} else {
echo json_encode(error("ortschaftskennziffer code was not valid"));
}
} else {
echo json_encode(error("Nation was not 'A' (Austria)"));
echo json_encode(error("Nation was not 'A' (Austria)"));
}
}
@@ -732,4 +750,6 @@ class Profil extends Auth_Controller
$zutrittskarte_ausgegebenam = str_replace("-", ".", $zutrittskarte_ausgegebenam);
return $zutrittskarte_ausgegebenam;
}
}
+2 -1
View File
@@ -64,7 +64,7 @@ class ProfilUpdate extends Auth_Controller
{
// Get file to be downloaded from DMS
$newFilename = $this->uid . "/document_" . $dms_id;
$download = $this->dmslib->download($dms_id);
$download = $this->dmslib->getOutputFileInfo($dms_id);
if (isError($download))
return $download;
@@ -84,3 +84,4 @@ class ProfilUpdate extends Auth_Controller
}
}
}
@@ -1,30 +0,0 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
*/
class ProjektabgabeUebersicht extends Auth_Controller
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct([
'index' => ['basis/cis:r']
]);
}
// -----------------------------------------------------------------------------------------------------------------
// Public methods
/**
* @return void
*/
public function index()
{
$this->load->view('CisRouterView/CisRouterView.php', ['route' => 'ProjektabgabeUebersicht']);
}
}
+48 -82
View File
@@ -29,10 +29,14 @@ class Pub extends Auth_Controller
*/
public function bild($source, $id)
{
$this->load->model('person/Person_model', 'PersonModel');
$person_id_user = '';
$person_id_user = getAuthPersonId();
$serverzugriff = false;
// Default Bild (Dummy Profilbild)
$outputFileName = FHCPATH . 'skin/images/profilbild_dummy.jpg';
$outputFileContent = '';
$mimetype = 'application/jpeg';
$this->load->model('person/Person_model', 'PersonModel');
// Wenn das Bild direkt aufgerufen wird, ist eine Authentifizierung erforderlich
// Wenn es vom Server selbst aufgerufen wird, ist keine Auth. notwendig
@@ -45,31 +49,27 @@ class Pub extends Auth_Controller
'zugangscode' => $_SESSION['incoming/user']
]);
if (hasData($result))
$person_id_user = current(getData($result))->person_id;
$person_id_user = getData($result)[0]->person_id;
} elseif (isset($_SESSION['prestudent/user'])) { // Von Prestudententool
$result = $this->PersonModel->loadWhere([
'zugangscode' => $_SESSION['prestudent/user']
]);
if (hasData($result))
$person_id_user = current(getData($result))->person_id;
$person_id_user = getData($result)[0]->person_id;
} elseif (isset($_SESSION['bewerbung/personId'])) { // Von Bewerbungstool
$person_id_user = $_SESSION['bewerbung/personId'];
} else {
$person_id_user = getAuthPersonId();
}
} else {
$serverzugriff = true;
}
// Default Bild (Dummy Profilbild)
$cTmpHEX = base64_encode(file_get_contents(FHCPATH . 'skin/images/profilbild_dummy.jpg'));
if ($source == 'person' && $id) {
// If the picture is from the person table
if ($source == 'person' && is_numeric($id)) {
$foto_gesperrt = false;
// Person laden und Fotosperre überprüfen
$result = $this->PersonModel->load($id);
if (hasData($result)) {
$person = current(getData($result));
$person = getData($result)[0];
if ($person->foto_sperre) {
// Wenn der User selbst darauf zugreift darf er das Bild sehen
$foto_gesperrt = ($person_id_user != $id);
@@ -77,91 +77,57 @@ class Pub extends Auth_Controller
$foto_gesperrt = true;
}
if ($person->foto && !$foto_gesperrt) {
$cTmpHEX = base64_decode($person->foto);
if (!isEmptyString($person->foto) && !$foto_gesperrt) {
$outputFileContent = base64_decode($person->foto);
}
}
}
if($source == 'akte' && $id != '')
// If the picture is from the akte/dms
if($source == 'akte' && is_numeric($id))
{
$this->load->model('crm/Akte_model', 'AkteModel');
$mimetype = '';
$this->load->library('AkteLib');
$this->AkteModel->addJoin('public.tbl_person', 'person_id');
$result = $this->AkteModel->loadWhere([
'person_id' => $id,
'dokument_kurzbz' => 'Lichtbil'
]);
$akteResult = $this->aktelib->getByAkteId($id, 'Lichtbil');
if (hasData($result)) {
if (hasData($akteResult)) {
$foto_gesperrt = false;
$akte = getData($akteResult)[0];
$akte = current(getData($result));
if ($akte->foto_sperre) {
// Wenn der User selbst darauf zugreift darf er das Bild sehen
$foto_gesperrt = ($person_id_user != $id);
} elseif (!$person_id_user && !$serverzugriff) {
$foto_gesperrt = true;
}
// Wenn das Foto nicht im Inhalt steht wird aus aus dem DMS geladen
if (!$akte->inhalt && $akte->dms_id) {
$this->load->model('content/Dms_model', 'DmsModel');
$this->load->model('content/DmsVersion_model', 'DmsVersionModel');
$this->DmsModel->addJoin('campus.tbl_dms_version', 'dms_id');
$this->DmsModel->addOrder('version', 'DESC');
$this->DmsModel->addLimit(1);
$result = $this->DmsModel->load($akte->dms_id);
if (!hasData($result))
die('Kein Dokument vorhanden');
$dms = current(getData($result));
$filename = DMS_PATH . $dms->filename;
$this->DmsVersionModel->update([
'dms_id' => $dms->dms_id,
'version' => $dms->version
], [
'letzterzugriff' => date('c')
]);
if (file_exists($filename)) {
$handle = fopen($filename, "r");
if ($handle) {
while (!feof($handle)) {
$akte->inhalt .= fread($handle, 8192);
}
fclose($handle);
} else {
echo 'Fehler: Datei konnte nicht geoeffnet werden';
}
} else {
echo 'Die Datei existiert nicht';
$personResult = $this->PersonModel->load($akte->person_id);
if (hasData($personResult)) {
$person = getData($personResult)[0];
if ($person->foto_sperre) {
$foto_gesperrt = ($person_id_user != $id);
} elseif (!$person_id_user && !$serverzugriff) {
$foto_gesperrt = true;
}
}
if ($akte->inhalt && !$foto_gesperrt) {
$cTmpHEX = $akte->inhalt;
// Wenn das Foto nicht im Inhalt steht wird aus aus dem DMS geladen
if (!isEmptyString($akte->inhalt)) {
$outputFileContent = base64_decode($akte->inhalt);
$mimetype = $akte->mimetype;
}
}
}
// die bilder werden, sofern es funktioniert, in jpg umgewandelt da es sonst zu fehlern beim erstellen
// von pdfs kommen kann.
$im = @imagecreatefromstring(base64_decode($cTmpHEX));
if ($im) {
@ob_clean();
header("Content-type: image/jpeg");
exit(imagejpeg($im));
} else {
// bei manchen Bildern funktioniert die konvertierung nicht
// diese werden dann einfach so angezeigt.
@ob_clean();
header("Content-type: image/gif");
exit($cTmpHEX);
// If file content is provided
if (!isEmptyString($outputFileContent))
{
// If a mimetype is still not found
if (isEmptyString($mimetype))
{
$fo = finfo_open();
$mimetype = finfo_buffer($fo, $outputFileContent, FILEINFO_MIME_TYPE);
}
$this->outputImageByContent($mimetype, $outputFileContent);
}
else // otherwise use the file
{
$this->outputImageByFile($mimetype, $outputFileName);
}
}
}
+6 -1
View File
@@ -25,6 +25,11 @@ class Raumsuche extends Auth_Controller
*/
public function index()
{
$this->load->view('CisRouterView/CisRouterView.php', ['route' => 'Raumsuche']);
$viewData = array(
'uid'=>getAuthUID(),
);
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'Raumsuche']);
}
}
@@ -1,33 +0,0 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
*/
class StgOrgLvPlan extends Auth_Controller
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct([
'index' => ['basis/cis:r']
]);
// Load Config
$this->load->config('calendar');
}
// -----------------------------------------------------------------------------------------------------------------
// Public methods
/**
* @return void
*/
public function index()
{
$this->load->view('CisRouterView/CisRouterView.php', ['route' => 'StgOrgLvPlan']);
}
}
+4 -1
View File
@@ -29,7 +29,10 @@ class Studium extends Auth_Controller
*/
public function index()
{
$this->load->view('CisRouterView/CisRouterView.php',['route' => 'studium']);
$viewData = array(
);
$this->load->view('CisRouterView/CisRouterView.php',['viewData' => $viewData, 'route' => 'studium']);
}
@@ -1,30 +0,0 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class Zeitsperren extends Auth_Controller
{
public function __construct()
{
parent::__construct([
'index' => ['basis/cis:r'],
]);
// Load Libraries
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
}
/**
* index loads the view Zeitsperren
* @access public
* @return void
*/
public function index()
{
$viewData = array(
'uid'=>getAuthUID(),
);
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'zeitsperren']);
}
}
+15 -6
View File
@@ -1,7 +1,6 @@
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
@@ -14,9 +13,9 @@ class Cis4 extends Auth_Controller
public function __construct()
{
parent::__construct(
array(
'index' => 'basis/cis:r'
)
array(
'index' => 'basis/cis:r'
)
);
// Load Config
@@ -31,6 +30,16 @@ class Cis4 extends Auth_Controller
*/
public function index()
{
$this->load->view('CisRouterView/CisRouterView.php', ['route' => 'FhcDashboard']);
$this->load->model('person/Person_model', 'PersonModel');
$personData = getData($this->PersonModel->getByUid(getAuthUID()))[0];
$viewData = array(
'uid' => getAuthUID(),
'name' => $personData->vorname,
'person_id' => $personData->person_id,
'timezone' => $this->config->item('timezone')
);
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'FhcDashboard']);
}
}
@@ -5,18 +5,18 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
*/
class Benotungstool extends Auth_Controller
class Dashboard extends Auth_Controller
{
/**
* Constructor
*/
public function __construct()
{
parent::__construct([
'index' => self::PERM_LOGGED
]);
$this->_ci =& get_instance();
parent::__construct(
array(
'index' => 'dashboard/benutzer:r'
)
);
}
// -----------------------------------------------------------------------------------------------------------------
@@ -27,11 +27,17 @@ class Benotungstool extends Auth_Controller
*/
public function index()
{
$viewData = array(
'uid'=>getAuthUID(),
);
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData, 'route' => 'Benotungstool']);
$this->load->model('person/Person_model','PersonModel');
$personData = getData($this->PersonModel->getByUid(getAuthUID()))[0];
$viewData = array(
'uid' => getAuthUID(),
'name' => $personData->vorname,
'person_id' => $personData->person_id
);
$this->load->view('CisRouterView/CisRouterView.php', ['viewData' => $viewData]);
}
}
+18 -6
View File
@@ -143,7 +143,7 @@ class Documents extends Auth_Controller
$result = $this->VorlagestudiengangModel->getCurrent($xsl, $xsl_oe_kurzbz, $version);
if (isError($result))
return show_error(getError($result));
show_error(getError($result));
if (!hasData($result))
return show_404();
@@ -226,13 +226,13 @@ class Documents extends Auth_Controller
$result = $this->VorlageModel->load($xsl);
if (isError($result))
return show_error(getError($result));
show_error(getError($result));
if (!hasData($result))
show_404();
$vorlage = current(getData($result));
if ($sign_user && !$vorlage->signierbar)
return show_error($this->p->t("stv", "grades_error_sign"));
show_error($this->p->t("stv", "grades_error_sign"));
// Filename
@@ -284,11 +284,23 @@ class Documents extends Auth_Controller
// XML Data
$result = $this->documentexportlib->getDataURL($xml, $params);
if (isError($result))
return show_error(getError($result));
show_error(getError($result));
$data = getData($result);
// Output
$this->documentexportlib->showContent($filename, $vorlage, $data, $xsl_oe_kurzbz, $version, $outputformat, $sign_user);
// Get the content
$contentResult = $this->documentexportlib->getContent($filename, $vorlage, $data, $xsl_oe_kurzbz, $version, $outputformat, $sign_user);
// If an error occurred
if (isError($contentResult)) show_error(getError($contentResult));
$fileObj = new stdClass();
$fileObj->file_content = getData($contentResult);
$fileObj->name = $filename;
$fileObj->mimetype = isEmptyString($vorlage->mimetype) ? 'application/pdf' : $vorlage->mimetype;
$fileObj->disposition = 'attachment';
// Download
$this->outputFile($fileObj);
}
}
@@ -18,8 +18,6 @@
if (! defined('BASEPATH')) exit('No direct script access allowed');
use \DateTime as DateTime;
class Bookmark extends FHCAPI_Controller
{
@@ -30,162 +28,111 @@ class Bookmark extends FHCAPI_Controller
{
parent::__construct([
'getBookmarks' => self::PERM_LOGGED,
'delete' => self::PERM_LOGGED,
'insert' => self::PERM_LOGGED,
'delete' => self::PERM_LOGGED,
'insert' => self::PERM_LOGGED,
'update' => self::PERM_LOGGED,
'changeOrder' => self::PERM_LOGGED
]);
]);
$this->load->model('dashboard/Bookmark_model', 'BookmarkModel');
$this->uid = getAuthUID();
$this->pid = getAuthPersonID();
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* gets the bookmarks associated to a user
/**
* gets the bookmarks associated to a user
* @access public
* @return void
*/
public function getBookmarks()
{
$this->BookmarkModel->addOrder("sort");
$this->BookmarkModel->addOrder("bookmark_id");
$bookmarks = $this->BookmarkModel->loadWhere(["uid"=>$this->uid]);
$bookmarks = $this->getDataOrTerminateWithError($bookmarks);
$bookmarks = $this->getDataOrTerminateWithError($bookmarks);
$this->terminateWithSuccess($bookmarks);
}
$this->terminateWithSuccess($bookmarks);
}
/**
* deletes bookmark from associated user
/**
* deletes bookmark from associated user
* @access public
* @return void
*/
public function delete($bookmark_id)
public function delete($bookmark_id)
{
$bookmark = $this->BookmarkModel->load($bookmark_id);
$bookmark = $this->BookmarkModel->load($bookmark_id);
$bookmark = current($this->getDataOrTerminateWithError($bookmark));
$bookmark = current($this->getDataOrTerminateWithError($bookmark));
// only delete bookmark if the user is the owner of the bookmark
if ($bookmark->uid == $this->uid || $this->permissionlib->isBerechtigt('admin')) {
$delete_result = $this->BookmarkModel->delete($bookmark_id);
// only delete bookmark if the user is the owner of the bookmark
if($bookmark->uid == $this->uid || $this->permissionlib->isBerechtigt('admin')){
$delete_result = $this->getDataOrTerminateWithError($delete_result);
$delete_result = $this->BookmarkModel->delete($bookmark_id);
$this->terminateWithSuccess($delete_result);
} else {
$this->_outputAuthError(['delete' => ['admin:rw']]);
}
}
$delete_result = $this->getDataOrTerminateWithError($delete_result);
/**
* inserts new bookmark into the bookmark table
$this->terminateWithSuccess($delete_result);
}else{
$this->_outputAuthError(['delete' => ['admin:rw']]);
}
}
/**
* inserts new bookmark into the bookmark table
* @access public
* @return void
*/
public function insert()
public function insert()
{
// form validation
$this->load->library('form_validation');
$this->form_validation->set_rules('url', 'URL', 'required|valid_url|max_length[511]');
$this->form_validation->set_rules('title', 'Title', 'required|max_length[255]');
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
// form validation
$this->load->library('form_validation');
$this->form_validation->set_rules('url', 'URL', 'required|valid_url|max_length[511]');
$this->form_validation->set_rules('title', 'Title', 'required|max_length[255]');
if($this->form_validation->run() == FALSE) $this->terminateWithValidationErrors($this->form_validation->error_array());
$url = $this->input->post('url', true);
$title = $this->input->post('title', true);
$tag = $this->input->post('tag', true);
if (is_array($tag)) {
$tag = json_encode($tag); // convert PHP array to JSON string
}
$sort = $this->input->post('sort', true);
$url = $this->input->post('url',true);
$title = $this->input->post('title',true);
$tag = $this->input->post('tag', true);
$insert_into_result = $this->BookmarkModel->insert([
'uid' => $this->uid,
'url' => $url,
'title' => $title,
'tag' => $tag,
'insertvon' => $this->uid,
'updateamum' => null,
'updatevon' => null,
'sort' => $sort
]);
$insert_into_result = $this->BookmarkModel->insert(['uid'=>$this->uid, 'url'=>$url, 'title'=>$title,'tag'=>$tag, 'insertvon'=>$this->uid, 'updateamum'=>NULL, 'updatevon'=>NULL]);
$insert_into_result = $this->getDataOrTerminateWithError($insert_into_result);
$insert_into_result = $this->getDataOrTerminateWithError($insert_into_result);
$this->terminateWithSuccess($insert_into_result);
}
$this->terminateWithSuccess($insert_into_result);
}
/**
* updates bookmark in the bookmark table
* updates bookmark in the bookmark table
* @access public
* @return void
*/
public function update($bookmark_id)
public function update($bookmark_id)
{
// form validation
$this->load->library('form_validation');
$this->form_validation->set_rules('url', 'URL', 'required|valid_url|max_length[511]');
$this->form_validation->set_rules('title', 'Title', 'required|max_length[255]');
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
// form validation
$this->load->library('form_validation');
$this->form_validation->set_rules('url', 'URL', 'required|valid_url|max_length[511]');
$this->form_validation->set_rules('title', 'Title', 'required|max_length[255]');
if($this->form_validation->run() == FALSE) $this->terminateWithValidationErrors($this->form_validation->error_array());
$url = $this->input->post('url', true);
$title = $this->input->post('title', true);
$tag = $this->input->post('tag', true);
if (is_array($tag)) {
$tag = json_encode($tag);
}
$url = $this->input->post('url',true);
$title = $this->input->post('title',true);
$now = new DateTime();
$now = $now->format('Y-m-d H:i:s');
$update_result = $this->BookmarkModel->update($bookmark_id, [
'url' => $url,
'title' => $title,
'tag' => $tag,
'updateamum' => $now
]);
$update_result = $this->BookmarkModel->update($bookmark_id,['url'=>$url, 'title'=>$title,'updateamum'=>$now]);
$update_result = $this->getDataOrTerminateWithError($update_result);
$update_result = $this->getDataOrTerminateWithError($update_result);
$this->terminateWithSuccess($update_result);
}
$this->terminateWithSuccess($update_result);
/**
* changes sort of two bookmarks in the bookmark table
* @access public
* @return void
*/
public function changeOrder($bookmark_id1, $bookmark_id2)
{
$update_result = [];
$result1 = $this->BookmarkModel->load($bookmark_id1);
$data1 = $this->getDataOrTerminateWithError($result1);
$sort1 = current($data1)->sort;
$result2 = $this->BookmarkModel->load(["bookmark_id"=>$bookmark_id2]);
$data2 = $this->getDataOrTerminateWithError($result2);
$sort2 = current($data2)->sort;
$update_result1 = $this->BookmarkModel->update($bookmark_id1, [
'sort' => $sort2
]);
$update_result[] = $this->getDataOrTerminateWithError($update_result1);
$update_result2 = $this->BookmarkModel->update($bookmark_id2, [
'sort' => $sort1
]);
$update_result[] = $this->getDataOrTerminateWithError($update_result2);
$this->terminateWithSuccess($update_result);
}
}
}
@@ -27,7 +27,7 @@ class Cis4FhcApi extends FHCAPI_Controller
public function __construct()
{
parent::__construct([
'dashboardViewData' => self::PERM_LOGGED,
'getViewData' => self::PERM_LOGGED,
]);
}
@@ -36,22 +36,17 @@ class Cis4FhcApi extends FHCAPI_Controller
// Public methods
/**
* retrieves view data for dashboard view
* @access public
* @param $uid the userID for which profile is being viewed, null or missing value implies one's own profile
*/
public function dashboardViewData()
* fetches ViewData
*/
public function getViewData()
{
$this->load->model('person/Person_model','PersonModel');
$personData = getData($this->PersonModel->getByUid(getAuthUID()))[0];
$this->load->config('calendar');
$viewData = array(
'uid' => getAuthUID(),
'name' => $personData->vorname,
'person_id' => $personData->person_id,
'timezone' => $this->config->item('timezone'),
'person_id' => $personData->person_id
);
$this->terminateWithSuccess($viewData);
@@ -16,13 +16,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (!defined('BASEPATH'))
exit('No direct script access allowed');
if (! defined('BASEPATH')) exit('No direct script access allowed');
class CisMenu extends FHCAPI_Controller
{
/**
* Object initialization
*/
@@ -32,95 +31,28 @@ class CisMenu extends FHCAPI_Controller
'getMenu' => self::PERM_LOGGED,
]);
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
/**
* fetches the menu for CIS from the database based on the userLanguage
*/
public function getMenu()
public function getMenu()
{
$this->load->model('content/Content_model', 'ContentModel');
$this->load->config('cis');
$cis4_content_id = $this->config->item('cis_menu_root_content_id');
$result = $this->ContentModel->getMenu($cis4_content_id, getAuthUID(), getUserLanguage());
$cis4_content_id =$this->config->item('cis_menu_root_content_id');
$result = $this->ContentModel->getMenu($cis4_content_id, getAuthUID(),getUserLanguage());
$result = $this->getDataOrTerminateWithError($result);
$menu = $result->childs ?? [];
$menu = $this->generateUrlsForMenuItems($menu);
$this->terminateWithSuccess($menu);
}
private function generateUrlsForMenuItems($menuItems)
{
return array_map(
function ($menuItem) {
return $this->generateUrlForMenuItem($menuItem);
},
$menuItems
);
}
private function generateUrlForMenuItem($menuItem)
{
$menuItem->url = $this->menuItemUrlHelper($menuItem);
unset($menuItem->content);
if ($menuItem->childs && count($menuItem->childs)) {
$menuItem->childs = $this->generateUrlsForMenuItems($menuItem->childs);
}
return $menuItem;
}
private function menuItemUrlHelper($menuItem)
{
if ($menuItem->template_kurzbz !== 'redirect') {
return site_url("/CisVue/Cms/content/" . $menuItem->content_id);
}
if (!$menuItem->content || !mb_strlen($menuItem->content)) {
return '';
}
$doc = new DOMDocument();
$doc->loadXML($menuItem->content);
$urlElem = $doc->getElementsByTagName('url')->item(0);
if (!$urlElem) {
return '';
}
$url = $urlElem->textContent;
if (strpos($url, '../cms/news.php') !== false) {
$newsRegex = '/^\.\.\/cms\/news\.php/';
$url = preg_replace($newsRegex, site_url("/CisVue/Cms/news"), $url);
}
if (strpos($url, '../cms/content.php?') !== false) {
$contentRegex = '/^\.\.\/cms\/content\.php\?content_id=([0-9]+)/';
$matches = [];
preg_match($contentRegex, $url, $matches);
$url = site_url('/CisVue/Cms/content/' . $matches[1]);
}
if (strpos($url, '../index.ci.php') !== false) {
$indexRegex = '/^\.\.\/index\.ci\.php/';
$url = preg_replace($indexRegex, site_url(), $url);
}
if (strpos($url, '../') !== false) {
$relativeRegex = '/^\.\.\//';
$url = preg_replace($relativeRegex, base_url(), $url);
}
return $url;
}
}
}
@@ -51,6 +51,8 @@ class Documents extends FHCAPI_Controller
$this->loadPhrases([
'stv'
]);
$this->load->library('DocumentExportLib');
}
/**
@@ -100,23 +102,11 @@ class Documents extends FHCAPI_Controller
{
$akteExportData = $this->_getAkteExportData($xml, $xsl, $sign_user);
$akteData = $akteData['akteData'];
$exportData = $akteData['exportData'];
/**
* [
'vorlage' => $vorlage,
'xml_data' => $data,
'oe_kurzbz' => $xsl_oe_kurzbz,
'version' => $version,
'outputformat' => $outputformat,
'sign_user' => $sign_user
]
*/
$akteData = $akteExportData['akteData'];
$exportData = $akteExportData['exportData'];
// Output
$result = $this->documentexportlib->showContent(
$akteData['akteData']['inhalt'],
$contentResult = $this->documentexportlib->getContent(
$exportData['vorlage'],
$exportData['xml_data'],
$exportData['oe_kurzbz'],
@@ -125,7 +115,9 @@ class Documents extends FHCAPI_Controller
$exportData['sign_user']
);
$this->terminateWithSuccess(true);
$content = $this->getDataOrTerminateWithError($contentResult);
$this->terminateWithFileOutput($akteData['mimetype'], $content, $akteData['titel'] . '.pdf');
}
/**
@@ -161,12 +153,10 @@ class Documents extends FHCAPI_Controller
$this->load->library('form_validation');
if (!$xml) {
$xml = $this->input->post_get('xml');
$this->addMeta('xml', $xml);
$this->form_validation->set_rules('xml', 'xml', 'required');
}
if (!$xsl) {
$xsl = $this->input->post_get('xsl');
$this->addMeta('xsl', $xsl);
$this->form_validation->set_rules('xsl', 'xsl', 'required');
}
@@ -465,18 +455,13 @@ class Documents extends FHCAPI_Controller
if ($sign_user && !$vorlage->signierbar)
$this->terminateWithError($this->p->t("stv", "grades_error_sign"));
$this->load->library('DocumentExportLib');
// XML Data
$result = $this->documentexportlib->getDataURL($xml, $params);
$data = $this->getDataOrTerminateWithError($result);
$this->documentexportlib->addArchiveToData($data);
$contentResult = $this->documentexportlib->getContent($vorlage, $data, $xsl_oe_kurzbz, $version, $outputformat, $sign_user);
// Output
$result = $this->documentexportlib->getContent($vorlage, $data, $xsl_oe_kurzbz, $version, $outputformat, $sign_user);
$content = $this->getDataOrTerminateWithError($result);
$content = $this->getDataOrTerminateWithError($contentResult);
$akteData['titel'] .= '.pdf';
$akteData['inhalt'] = base64_encode($content);
@@ -494,3 +479,4 @@ class Documents extends FHCAPI_Controller
];
}
}
+29 -124
View File
@@ -18,9 +18,18 @@
if (! defined('BASEPATH')) exit('No direct script access allowed');
//require_once('../../../include/studiengang.class.php');
//require_once('../../../include/student.class.php');
//require_once('../../../include/datum.class.php');
//require_once('../../../include/mail.class.php');
//require_once('../../../include/benutzerberechtigung.class.php');
//require_once('../../../include/phrasen.class.php');
//require_once('../../../include/projektarbeit.class.php');
//require_once('../../../include/projektbetreuer.class.php');
class Lehre extends FHCAPI_Controller
{
/**
* Object initialization
*/
@@ -29,58 +38,39 @@ class Lehre extends FHCAPI_Controller
parent::__construct([
'lvStudentenMail' => self::PERM_LOGGED,
'LV' => self::PERM_LOGGED,
'Pruefungen' => self::PERM_LOGGED,
'semesterAverageGrade' => self::PERM_LOGGED,
'getZugewieseneLv' => self::PERM_LOGGED,
'getLeForLv' => self::PERM_LOGGED
'Pruefungen' => self::PERM_LOGGED
]);
$this->load->library('PhrasesLib');
$this->loadPhrases(
array(
'global',
'ui',
'abgabetool'
)
);
$this->load->helper('hlp_sancho_helper');
require_once(FHCPATH . 'include/studiengang.class.php');
require_once(FHCPATH . 'include/student.class.php');
require_once(FHCPATH . 'include/projektarbeit.class.php');
require_once(FHCPATH . 'include/projektbetreuer.class.php');
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
/**
* constructs the emails of the groups from a lehrveranstaltung
*/
public function lvStudentenMail()
public function lvStudentenMail()
{
$lehreinheit_id = $this->input->get("lehreinheit_id",TRUE);
$lehreinheit_id = $this->input->get("lehreinheit_id",TRUE);
// return early if the required parameter is missing
if(!isset($lehreinheit_id))
{
$this->terminateWithError('Missing required parameter', self::ERROR_TYPE_GENERAL);
}
// return early if the required parameter is missing
if(!isset($lehreinheit_id))
{
$this->terminateWithError('Missing required parameter', self::ERROR_TYPE_GENERAL);
}
$this->load->model('education/Lehreinheit_model', 'LehreinheitModel');
$studentenMails = $this->LehreinheitModel->getStudentenMail($lehreinheit_id);
$this->load->model('education/Lehreinheit_model', 'LehreinheitModel');
$studentenMails = $this->LehreinheitModel->getStudentenMail($lehreinheit_id);
$studentenMails = $this->getDataOrTerminateWithError($studentenMails);
$studentenMails = $this->getDataOrTerminateWithError($studentenMails);
//convert array of objects into array of strings
$studentenMails = array_map(function($element){
return $element->mail;
}, $studentenMails);
$this->terminateWithSuccess($studentenMails);
$this->terminateWithSuccess($studentenMails);
}
public function LV($studiensemester_kurzbz, $lehrveranstaltung_id)
@@ -90,13 +80,13 @@ class Lehre extends FHCAPI_Controller
$result = $this->LehrveranstaltungModel->getLvsByStudentWithGrades(getAuthUID(), $studiensemester_kurzbz, getUserLanguage(), $lehrveranstaltung_id);
$result = current($this->getDataOrTerminateWithError($result));
$this->terminateWithSuccess($result);
}
/**
* fetches all Pruefungen of a student for a specific lehrveranstaltung
* if the student passed the Pruefung on the first attempt, no information about the Pruefungen is stored in the database
* if the student passed the Pruefung on the first attempt, no information about the Pruefungen is stored in the database
* @param mixed $lehrveranstaltung_id
* @return void
*/
@@ -110,90 +100,5 @@ class Lehre extends FHCAPI_Controller
$this->terminateWithSuccess($result);
}
/**
* calculates and returns the grade average and weighted average for a specific semester
* @param string $studiensemester_kurzbz
* @return void
*/
public function semesterAverageGrade($studiensemester_kurzbz)
{
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
$semesterLvs = $this->LehrveranstaltungModel->getLvsByStudentWithGrades(getAuthUID(), $studiensemester_kurzbz, getUserLanguage());
if (isError($semesterLvs))
return $this->outputJsonError(getError($semesterLvs));
$semesterLvsData = getData($semesterLvs);
$doGradesExist = false;
$sum = 0;
$count = 0;
$sumWeighted = 0;
$sumEcts = 0;
foreach ($semesterLvsData as $lv) {
if (!$lv->znote || $lv->znote < 1 || $lv->znote > 5)
continue;
$doGradesExist = true;
$sum += $lv->znote;
$count++;
$sumWeighted += $lv->znote * floatval($lv->ects);
$sumEcts += floatval($lv->ects);
}
$averageGrade = null;
$weightedAverageGrade = null;
if ($doGradesExist) {
$averageGrade = $sum/$count;
$weightedAverageGrade = $sumWeighted/$sumEcts;
}
$this->terminateWithSuccess(['average_grade' => $averageGrade, 'weighted_average_grade' => $weightedAverageGrade]);
}
/**
* fetches all assigned lehrveranstaltungen of a mitarbeiter for a given semester
* @param mixed $uid
* @param mixed $sem_kurzbz
* @return void
*/
public function getZugewieseneLv() {
$uid = $this->input->get("uid",TRUE);
$sem_kurzbz = $this->input->get("sem_kurzbz",TRUE);
// TODO: error messages
if(!isset($sem_kurzbz) || isEmptyString($sem_kurzbz))
$this->terminateWithError($this->p->t('global', 'wrongParameters'), 'general');
if (!isset($uid) || isEmptyString($uid))
$uid = getAuthUID();
// querying other ma_uids data requires admin permission
if($uid !== getAuthUID()) {
$this->load->library('PermissionLib');
$isAdmin = $this->permissionlib->isBerechtigt('admin');
if(!$isAdmin) $this->terminateWithError($this->p->t('ui', 'keineBerechtigung'), 'general');
}
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
$result = $this->LehrveranstaltungModel->getLvForLektorInSemester($sem_kurzbz, $uid);
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
public function getLeForLv() {
$lv_id = $this->input->get("lv_id",TRUE);
$sem_kurzbz = $this->input->get("sem_kurzbz",TRUE);
$this->load->model('education/Lehreinheit_model', 'LehreinheitModel');
// $this->terminateWithSuccess($this->LehreinheitModel->getLesForLv($lv_id, $sem_kurzbz));
$this->terminateWithSuccess($this->LehreinheitModel->getAllLehreinheitenForLvaAndMaUid($lv_id, getAuthUID(), $sem_kurzbz));
}
}
@@ -36,8 +36,7 @@ class LvMenu extends FHCAPI_Controller
public function __construct()
{
parent::__construct([
'getLvMenu' => self::PERM_LOGGED,
'getMultipleLvMenu' => self::PERM_LOGGED
'getLvMenu' => self::PERM_LOGGED
]);
$this->load->model("ressource/Mitarbeiter_model");
@@ -62,23 +61,24 @@ class LvMenu extends FHCAPI_Controller
/**
* alternative function to get multiple lvMenus with a single http request
* not yet working as intended as the menu_lv.inc.php scripts called by the
* lvMenuBuild event have logic coupled to require_once import which results in
* a wrong logic after the first invocation -> faulty results for lvinfo, moodle
* and several others
*/
public function getMultipleLvMenu(){
$lvMenuOptionList = $this->input->post('lvMenuOptionList', true);
public function getMultipleLvMenu($lvMenuOptionList){
$result =[];
foreach($lvMenuOptionList as $lvMenuOptions){
$lvMenu = $this->getLvMenuInternal($lvMenuOptions['lvid'],$lvMenuOptions['studiensemester_kurzbz']);
$lvMenu = $this->getLvMenu($lvMenuOptions['lvid'],$lvMenuOptions['studiensemester_kurzbz']);
if(isError($lvMenu)){
// TODO: some lvMenu threw an error, handle error here
}
$result[$lvMenuOptions['lvid']]=$lvMenu;
}
$this->terminateWithSuccess($result);
}
private function getLvMenuInternal($lvid, $studiensemester_kurzbz) {
/**
*
*/
public function getLvMenu($lvid, $studiensemester_kurzbz)
{
// return early if parameters are missing
if(!isset($lvid) || !isset($studiensemester_kurzbz))
@@ -89,14 +89,14 @@ class LvMenu extends FHCAPI_Controller
// get the user
if (!$user=getAuthUID())
$this->terminateWithError($this->p->t('global', 'nichtAngemeldet'));
$this->terminateWithError($this->p->t('global', 'nichtAngemeldet'));
// check if is_lector
$is_lector = false;
$mares = $this->Mitarbeiter_model->isMitarbeiter($user);
if(hasData($mares))
{
$is_lector = getData($mares);
$is_lector = getData($mares);
}
// definition of user_is_allowed_to_upload
@@ -105,7 +105,7 @@ class LvMenu extends FHCAPI_Controller
// load lehrveranstaltung
$lvres = $this->Lehrveranstaltung_model->load($lvid);
if(!hasData($lvres))
if(!hasData($lvres))
{
$this->terminateWithError('LV ' . $lvid . ' not found.');
}
@@ -124,7 +124,7 @@ class LvMenu extends FHCAPI_Controller
$stgres = $this->Studiengang_model->load(strval($studiengang_kz));
if(!hasData($stgres))
{
$this->terminateWithError('Stg ' . $lv->studiengang_kz . ' not found.');
$this->terminateWithError('Stg ' . $lv->studiengang_kz . ' not found.');
}
$stg = (getData($stgres))[0];
$kurzbz = strtoupper($stg->typ . $stg->kurzbz);
@@ -139,7 +139,7 @@ class LvMenu extends FHCAPI_Controller
$angemeldet = false;
$lesres = $this->Lehreinheit_model->getLehreinheitenForStudentAndStudienSemester(
$lvid, $user, $angezeigtes_stsem
$lvid, $user, $angezeigtes_stsem
);
if(hasData($lesres) && count(getData($lesres)) > 0)
@@ -148,7 +148,7 @@ class LvMenu extends FHCAPI_Controller
// lehrfach
$lehrfach_id='';
if(defined('CIS_LEHRVERANSTALTUNG_LEHRFACH_ANZEIGEN') && CIS_LEHRVERANSTALTUNG_LEHRFACH_ANZEIGEN)
{
// Wenn der eingeloggte User zu einer der Lehreinheiten zugeteilt ist
@@ -211,8 +211,8 @@ class LvMenu extends FHCAPI_Controller
foreach($fbs as $row)
{
$lehrfach_oe_kurzbz_arr[] = $row->oe_kurzbz;
if($this->PermissionLib->isBerechtigt('lehre', null, $row->oe_kurzbz)
|| $this->PermissionLib->isBerechtigt('assistenz', null, $stg->oe_kurzbz))
if($this->PermissionLib->isBerechtigt('lehre', null, $row->oe_kurzbz)
|| $this->PermissionLib->isBerechtigt('assistenz', null, $stg->oe_kurzbz))
{
$user_is_allowed_to_upload=true;
}
@@ -224,21 +224,21 @@ class LvMenu extends FHCAPI_Controller
$menu = array();
$this->fhc_menu_lvinfo($menu, $lvid, $studiengang_kz, $lektor_der_lv, $is_lector, $lehrfach_oe_kurzbz_arr);
$this->fhc_menu_feedback($menu, $angemeldet, $lvid);
$this->fhc_menu_gesamtnote($menu, $angemeldet, $lvid, $lv, $is_lector, $angezeigtes_stsem);
$this->fhc_menu_emailStudierende($menu, $user, $angemeldet, $lvid, $angezeigtes_stsem);
$this->fhc_menu_abmeldung($menu, $user, $is_lector, $lvid, $angezeigtes_stsem);
$this->fhc_menu_lehretools($menu, $lvid, $angezeigtes_stsem, $sprache);
$this->fhc_menu_anrechnungStudent($menu, $lvid, $angezeigtes_stsem);
$this->fhc_menu_anrechnungLector($menu, $angezeigtes_stsem);
// Addons Menu Logic
// ##########################################################################################
@@ -272,18 +272,18 @@ class LvMenu extends FHCAPI_Controller
'permissionLib' => &$this->PermissionLib,
'phrasesLib' => &$this->PhrasesLib
];
Events::trigger('lvMenuBuild',
// passing $menu per reference
function & () use (&$menu) {
return $menu;
},
$params
Events::trigger('lvMenuBuild',
// passing $menu per reference
function & () use (&$menu) {
return $menu;
},
$params
);
// Menu sortieren
// ##########################################################################################
foreach ($menu as $key => $row){
// removes menu points that are not needed in the c4 lvUebersicht
@@ -291,7 +291,7 @@ class LvMenu extends FHCAPI_Controller
unset($menu[$key]);
continue;
}
// fills pos array to sort the menu
$pos[$key] = $row['position'];
@@ -299,18 +299,11 @@ class LvMenu extends FHCAPI_Controller
array_multisort($pos, SORT_ASC, SORT_NUMERIC, $menu);
return $menu;
}
/**
*
*/
public function getLvMenu($lvid, $studiensemester_kurzbz)
{
$menu = $this->getLvMenuInternal($lvid, $studiensemester_kurzbz);
// HTTP response
// ##########################################################################################
$this->terminateWithSuccess($menu);
}
private function fhc_menu_lvinfo(&$menu, $lvid, $studiengang_kz, $lektor_der_lv, $is_lector, $lehrfach_oe_kurzbz_arr){
@@ -16,8 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (!defined('BASEPATH'))
exit('No direct script access allowed');
if (! defined('BASEPATH')) exit('No direct script access allowed');
use CI3_Events as Events;
use \DateTime as DateTime;
@@ -34,25 +33,19 @@ class LvPlan extends FHCAPI_Controller
parent::__construct([
'getRoomplan' => self::PERM_LOGGED,
'Stunden' => self::PERM_LOGGED,
'getReservierungen' => self::PERM_LOGGED,
'Stunden' => self::PERM_LOGGED,
'getReservierungen' => self::PERM_LOGGED,
'LvPlanEvents' => self::PERM_LOGGED,
'eventsPersonal' => self::PERM_LOGGED,
'eventsLv' => self::PERM_LOGGED,
'getLehreinheitStudiensemester' => self::PERM_LOGGED,
'studiensemesterDateInterval' => self::PERM_LOGGED,
'getLvPlanForStudiensemester' => self::PERM_LOGGED,
'getLv' => self::PERM_LOGGED,
'eventsStgOrg' => self::PERM_LOGGED,
'fetchFerienEvents' => self::PERM_LOGGED,
'getStudiengaenge' => self::PERM_LOGGED,
'getLehrverband' => self::PERM_LOGGED,
'permissionOtherLvPlan' => self::PERM_LOGGED,
'compactibleEventTypes' => self::PERM_LOGGED,
'getLv' => self::PERM_LOGGED
]);
$this->load->library('LogLib');
$this->loglib->setConfigs(array(
$this->load->library('LogLib');
$this->loglib->setConfigs(array(
'classIndex' => 5,
'functionIndex' => 5,
'lineIndex' => 4,
@@ -60,17 +53,17 @@ class LvPlan extends FHCAPI_Controller
'dbExecuteUser' => 'RESTful API'
));
$this->load->library('form_validation');
$this->load->library('form_validation');
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* fetches LvPlan and Moodle events together
* @access public
*
*/
* fetches LvPlan and Moodle events together
* @access public
*
*/
public function LvPlanEvents()
{
$hasLv = $this->input->post('lv_id');
@@ -90,30 +83,24 @@ class LvPlan extends FHCAPI_Controller
// form validation
$this->form_validation->set_rules('start_date', "start_date", "required");
$this->form_validation->set_rules('end_date', "end_date", "required");
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
// storing the post parameter in local variables
$start_date = $this->input->post('start_date', true);
$end_date = $this->input->post('end_date', true);
$uid = $this->input->post('uid', true);
// disallow accessing other user's events if missing permission
if ($uid && $uid !== getAuthUID() && !$this->permissionlib->isBerechtigt('basis/other_lv_plan')) {
$this->terminateWithError("Missing permission to view other users' timetables!");
}
// fetching lvplan events
$result = $this->stundenplanlib->getEventsUser($start_date, $end_date, $uid);
$result = $this->stundenplanlib->getEventsUser($start_date, $end_date);
$lvplanEvents = $this->getDataOrTerminateWithError($result);
// fetching moodle events
$moodleEvents = $this->fetchMoodleEvents($start_date, $end_date, $uid);
$moodleEvents = $this->fetchMoodleEvents($start_date, $end_date);
// fetching ferien events
$ferienEvents = $this->fetchFerienEvents($start_date, $end_date, $uid);
$ferienEvents = $this->fetchFerienEvents($start_date, $end_date);
$this->terminateWithSuccess(array_merge(
$lvplanEvents,
@@ -122,45 +109,6 @@ class LvPlan extends FHCAPI_Controller
));
}
/**
* fetches LvPlan for studiengang / semester / verband / gruppe
*
* @access public
*/
public function eventsStgOrg()
{
$this->load->library('StundenplanLib');
// form validation
$this->form_validation->set_rules('start_date', "start_date", "required");
$this->form_validation->set_rules('end_date', "end_date", "required");
//$this->form_validation->set_rules('stg_kz', "stg_kz", "required"); //no validation show empty calendar
if (!$this->form_validation->run()) {
$this->terminateWithValidationErrors($this->form_validation->error_array());
$stgOrgEvents = [];
$ferienEvents = [];
} else {
$start_date = $this->input->post('start_date', true);
$end_date = $this->input->post('end_date', true);
$stg_kz = $this->input->post('stg_kz', true);
$sem = $this->input->post('sem', true);
$verband = $this->input->post('verband', true);
$gruppe = $this->input->post('gruppe', true);
$result = $this->stundenplanlib->getEventsStgOrg($start_date, $end_date, $stg_kz, $sem, $verband, $gruppe);
$stgOrgEvents = $this->getDataOrTerminateWithError($result);
$result = $this->stundenplanlib->fetchFerienTageEvents($start_date, $end_date, $stg_kz);
$ferienEvents = $this->getDataOrTerminateWithError($result);
}
$this->terminateWithSuccess(array_merge(
$stgOrgEvents,
$ferienEvents
));
}
/**
* fetches LvPlan and Ferien events together for the lv
*
@@ -174,7 +122,7 @@ class LvPlan extends FHCAPI_Controller
$this->form_validation->set_rules('start_date', "start_date", "required");
$this->form_validation->set_rules('end_date', "end_date", "required");
$this->form_validation->set_rules('lv_id', "lv_id", "required|integer");
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
@@ -189,6 +137,7 @@ class LvPlan extends FHCAPI_Controller
// fetching ferien events
$ferienEvents = $this->fetchFerienEvents($start_date, $end_date);
$this->terminateWithSuccess(array_merge(
$lvplanEvents,
@@ -197,42 +146,40 @@ class LvPlan extends FHCAPI_Controller
}
//TODO: delete this function if we don't use the old calendar export endpoints anymore
public function studiensemesterDateInterval($date)
{
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$studiensemester = $this->StudiensemesterModel->getByDate(date_format(date_create($date), 'Y-m-d'));
$studiensemester = current($this->getDataOrTerminateWithError($studiensemester));
public function studiensemesterDateInterval($date){
$this->load->model('organisation/Studiensemester_model','StudiensemesterModel');
$studiensemester =$this->StudiensemesterModel->getByDate(date_format(date_create($date),'Y-m-d'));
$studiensemester =current($this->getDataOrTerminateWithError($studiensemester));
$this->terminateWithSuccess($studiensemester);
}
public function getLvPlanForStudiensemester($studiensemester, $lvid)
{
public function getLvPlanForStudiensemester($studiensemester,$lvid){
$this->load->library('StundenplanLib');
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$studiensemester_result = $this->StudiensemesterModel->loadWhere(["studiensemester_kurzbz" => $studiensemester]);
$this->load->model('organisation/Studiensemester_model','StudiensemesterModel');
$studiensemester_result = $this->StudiensemesterModel->loadWhere(["studiensemester_kurzbz"=>$studiensemester]);
$studiensemester_result = current($this->getDataOrTerminateWithError($studiensemester_result));
$timespan_start = new DateTime($studiensemester_result->start);
$timespan_ende = new DateTime($studiensemester_result->ende);
$lvplan = $this->stundenplanlib->getStundenplan(date_format($timespan_start, 'Y-m-d'), date_format($timespan_ende, 'Y-m-d'), $lvid);
$lvplan = $this->stundenplanlib->getStundenplan(date_format($timespan_start, 'Y-m-d'),date_format($timespan_ende, 'Y-m-d'), $lvid);
$this->terminateWithSuccess($lvplan);
}
/**
* fetches Stunden layout from database
* @access public
*
*/
public function Stunden()
/**
* fetches Stunden layout from database
* @access public
*
*/
public function Stunden()
{
$this->load->model('ressource/Stunde_model', 'StundeModel');
$this->StundeModel->addOrder('stunde', 'ASC');
$stunden = $this->StundeModel->load();
$stunden = $this->getDataOrTerminateWithError($stunden);
$stunden = $this->getDataOrTerminateWithError($stunden);
$this->terminateWithSuccess($stunden);
}
@@ -263,10 +210,10 @@ class LvPlan extends FHCAPI_Controller
$roomplan_data = $this->stundenplanlib->getRoomplan($ort_kurzbz, $start_date, $end_date);
$roomplan_data = $this->getDataOrTerminateWithError($roomplan_data);
$this->terminateWithSuccess($roomplan_data);
}
/**
* gets the reservierungen of a room if the ort_kurzbz parameter is
* supplied otherwise gets the reservierungen of the lvplan of a student
@@ -279,32 +226,25 @@ class LvPlan extends FHCAPI_Controller
{
$this->form_validation->set_rules('start_date', "StartDate", "required");
$this->form_validation->set_rules('end_date', "EndDate", "required");
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
// storing the post parameter in local variables
$start_date = $this->input->post('start_date', true);
$end_date = $this->input->post('end_date', true);
$uid = $this->input->post('uid', true);
// disallow accessing other user's reservierungen if missing permission
if ($uid && $uid !== getAuthUID() && !$this->permissionlib->isBerechtigt('basis/other_lv_plan')) {
$this->terminateWithError("Missing permission to view other users' timetables!");
}
// get data
$this->load->library('StundenplanLib');
$result = $this->stundenplanlib->getReservierungen($start_date, $end_date, $ort_kurzbz, $uid);
$result = $this->stundenplanlib->getReservierungen($start_date, $end_date, $ort_kurzbz);
$result = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($result);
}
public function getLehreinheitStudiensemester($lehreinheit_id)
{
public function getLehreinheitStudiensemester($lehreinheit_id){
$this->load->model('education/Lehreinheit_model', 'LehreinheitModel');
$this->LehreinheitModel->addSelect(["studiensemester_kurzbz"]);
$result = $this->LehreinheitModel->load($lehreinheit_id);
@@ -347,68 +287,6 @@ class LvPlan extends FHCAPI_Controller
return $this->terminateWithSuccess(current($result));
}
public function getStudiengaenge()
{
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
$this->StudiengangModel->addOrder('typ');
$this->StudiengangModel->addOrder('kurzbz');
$result = $this->StudiengangModel->loadWhere([
'aktiv' => true
]);
$data = $this->getDataOrTerminateWithError($result);
return $this->terminateWithSuccess($data);
}
public function getLehrverband($studiengang_kz, $semester = null, $verband = null)
{
$this->load->model('organisation/Lehrverband_model', 'LehrverbandModel');
$where = [
'aktiv' => true,
'studiengang_kz' => $studiengang_kz,
];
if ($semester !== null && $semester !== 'null' && $semester !== 'undefined') {
$where['semester'] = $semester;
}
if ($verband !== null && $verband !== 'null' && $verband !== 'undefined') {
$where['verband'] = $verband;
}
$this->LehrverbandModel->addOrder('studiengang_kz');
$this->LehrverbandModel->addOrder('semester');
$this->LehrverbandModel->addOrder('verband');
$this->LehrverbandModel->addOrder('gruppe');
$result = $this->LehrverbandModel->loadWhere($where);
$data = $this->getDataOrTerminateWithError($result);
return $this->terminateWithSuccess($data);
}
/**
* Checks if the current user has permission to view other users' timetables
*
* @return void
*/
public function permissionOtherLvPlan()
{
$this->terminateWithSuccess($this->permissionlib->isBerechtigt('basis/other_lv_plan'));
}
/**
* get event types which can be compacted in lv plan display
*
* @return void
*/
public function compactibleEventTypes()
{
$this->terminateWithSuccess(["lehreinheit", "reservierung", "ferien", "moodle"]);
}
/**
* fetch moodle events
*
@@ -416,30 +294,30 @@ class LvPlan extends FHCAPI_Controller
* @param string $end_date
* @return array
*/
private function fetchMoodleEvents($start_date, $end_date, $uid = null)
private function fetchMoodleEvents($start_date, $end_date)
{
$this->load->config('calendar');
$tz = new DateTimeZone($this->config->item('timezone'));
$start = new DateTime($start_date);
$start->setTimezone($tz);
$end = new DateTime($end_date);
$end->setTimezone($tz);
$end->modify('+1 day -1 second');
$moodle_events = [];
Events::trigger(
'moodleCalendarEvents',
function &() use (&$moodle_events) {
function & () use (&$moodle_events) {
return $moodle_events;
},
[
'start_date' => $start->format('c'),
'end_date' => $end->format('c'),
'username' => $uid ?? getAuthUID()
'username' => getAuthUID()
]
);
@@ -453,23 +331,23 @@ class LvPlan extends FHCAPI_Controller
* @param string $end_date
* @return array
*/
private function fetchFerienEvents($start_date, $end_date, $uid = null)
private function fetchFerienEvents($start_date, $end_date)
{
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$this->load->model('education/Studentlehrverband_model', 'StudentLehrverbandModel');
$currentStudiensemester = $this->StudiensemesterModel->getByDate($start_date);
$currentStudiensemester = $this->getDataOrTerminateWithError($currentStudiensemester);
if ($currentStudiensemester) {
$studentsemester_kurzbz = current($currentStudiensemester)->studiensemester_kurzbz;
$studiengang = $this->StudentLehrverbandModel->loadWhere([
"student_uid" => $uid ?? getAuthUID(),
"student_uid" => getAuthUID(),
"studiensemester_kurzbz" => $studentsemester_kurzbz
]);
$studiengang = $this->getDataOrTerminateWithError($studiengang);
if ($studiengang)
$studiengang_kz = current($studiengang)->studiengang_kz;
else
@@ -479,7 +357,7 @@ class LvPlan extends FHCAPI_Controller
}
$ferienEvents = $this->stundenplanlib->fetchFerienTageEvents($start_date, $end_date, $studiengang_kz);
return $this->getDataOrTerminateWithError($ferienEvents);
}
}
File diff suppressed because it is too large Load Diff
@@ -1,76 +0,0 @@
<?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 OtherLvPlan extends FHCAPI_Controller
{
/**
* Object initialization
*/
public function __construct()
{
parent::__construct([
'otherLvPlanViewData' => ['basis/other_lv_plan:r'],
]);
$this->load->model('ressource/mitarbeiter_model', 'MitarbeiterModel');
$this->load->model('person/Benutzer_model', 'BenutzerModel');
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* retrieves viewData for other lv plan view
* @access public
* @param $uid the userID for which the other lv plan is being viewed
*/
public function otherLvPlanViewData($uid)
{
$isMitarbeiterResult = $this->MitarbeiterModel->isMitarbeiter($uid);
$isMitarbeiter = getData($isMitarbeiterResult);
$isStudent = !$isMitarbeiter;
$this->BenutzerModel->addSelect(["foto", "vorname", "nachname"]);
$this->BenutzerModel->addJoin("tbl_person", "person_id");
$personResult = $this->BenutzerModel->load([$uid]);
$person = hasData($personResult) ? getData($personResult) : null;
$viewData = [
"user_data" => [
"username" => $uid,
"is_student" => $isStudent,
"is_mitarbeiter" => $isMitarbeiter,
"foto" => $person[0]->foto,
"vorname" => $person[0]->vorname,
"nachname" => $person[0]->nachname,
],
];
$this->terminateWithSuccess($viewData);
}
// -----------------------------------------------------------------------------------------------------------------
// Private methods
}
@@ -16,8 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (!defined('BASEPATH'))
exit('No direct script access allowed');
if (! defined('BASEPATH')) exit('No direct script access allowed');
class Profil extends FHCAPI_Controller
{
@@ -28,13 +27,13 @@ class Profil extends FHCAPI_Controller
public function __construct()
{
parent::__construct([
'fotoSperre' => self::PERM_LOGGED,
'fotoSperre' => self::PERM_LOGGED,
'getGemeinden' => self::PERM_LOGGED,
'getAllNationen' => self::PERM_LOGGED,
'isMitarbeiter' => self::PERM_LOGGED,
'profilViewData' => self::PERM_LOGGED,
]);
$this->load->library('PermissionLib');
$this->load->model('ressource/mitarbeiter_model', 'MitarbeiterModel');
@@ -49,37 +48,28 @@ class Profil extends FHCAPI_Controller
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* retrieves view data for profile view
* @access public
* @param $uid the userID for which profile is being viewed, null or missing value implies one's own profile
*/
public function profilViewData($uid = null)
{
$authUid = getAuthUID();
$isProfilOfAuthUser = !$uid || $uid === $authUid;
public function profilViewData($uid=null){
$this->load->library('ProfilLib');
$profileData = $this->profillib->getView($uid ?? $authUid);
$profileData = hasData($profileData) ? getData($profileData) : null;
$viewData = [
'editable' => $isProfilOfAuthUser,
'profil_data' => $profileData,
'permissions' => [
'basis/other_lv_plan' => $this->permissionlib->isBerechtigt(('basis/other_lv_plan'))
]
];
if ($isProfilOfAuthUser) {
$viewData['calendar_sync_urls'] = $this->getCalendarSyncUrlData();
$editable = false;
if(isset($uid) && $uid != null){
$profil_data = $this->profillib->getView($uid);
if($uid == getAuthUID()){
$editable = true;
}
}else{
$editable = true;
$profil_data = $this->profillib->getView(getAuthUID());
}
$profil_data = hasData($profil_data) ? getData($profil_data) : null;
$viewData = array(
'editable'=>$editable,
'profil_data' => $profil_data,
);
$this->terminateWithSuccess($viewData);
}
/**
/**
* update column foto_sperre in public.tbl_person
* @access public
* @param boolean $value new value for the column
@@ -87,9 +77,9 @@ class Profil extends FHCAPI_Controller
*/
public function fotoSperre($value)
{
if (!isset($value)) {
$this->terminateWithError("Missing parameter", self::ERROR_TYPE_GENERAL);
}
if(!isset($value)){
$this->terminateWithError("Missing parameter", self::ERROR_TYPE_GENERAL);
}
$res = $this->PersonModel->update($this->pid, ["foto_sperre" => $value]);
if (isError($res)) {
@@ -97,10 +87,10 @@ class Profil extends FHCAPI_Controller
}
$this->PersonModel->addSelect("foto_sperre");
$res = $this->PersonModel->load($this->pid);
$res = $this->getDataOrTerminateWithError($res);
$this->terminateWithSuccess(current($res));
$res = $this->getDataOrTerminateWithError($res);
$this->terminateWithSuccess(current($res));
}
/**
@@ -119,7 +109,7 @@ class Profil extends FHCAPI_Controller
if (isError($nation_res)) {
$this->terminateWithError("error while trying to query table codex.tbl_nation", self::ERROR_TYPE_GENERAL);
}
$nation_res = $this->getDataOrTerminateWithError($nation_res);
$this->terminateWithSuccess($nation_res);
@@ -127,30 +117,30 @@ class Profil extends FHCAPI_Controller
public function getGemeinden($nation, $zip)
{
if (!isset($nation) || !isset($zip)) {
if(!isset($nation) || !isset($zip)){
echo json_encode(error("Missing parameters"));
return;
}
$this->load->model('codex/Gemeinde_model', "GemeindeModel");
$gemeinde_res = $this->GemeindeModel->getGemeindeByPlz($zip);
if (isError($gemeinde_res)) {
$this->terminateWithError(getError($gemeinde_res), self::ERROR_TYPE_GENERAL);
$this->terminateWithError(getError($gemeinde_res),self::ERROR_TYPE_GENERAL);
}
$gemeinde_res = $this->getDataOrTerminateWithError($gemeinde_res);
/* $gemeinde_res = array_map(function ($obj) {
return $obj->ortschaftsname;
}, $gemeinde_res); */
$this->terminateWithSuccess($gemeinde_res);
$this->terminateWithSuccess($gemeinde_res);
}
/**
* checks whether a specific userID is a mitarbeiter or not (foreword declaration of the function isMitarbeiter in Mitarbeiter_model.php)
* @access public
@@ -160,48 +150,23 @@ class Profil extends FHCAPI_Controller
public function isMitarbeiter($uid)
{
if (!$uid)
$this->terminateWithError("No uid provided", self::ERROR_TYPE_GENERAL);
if(!$uid) $this->terminateWithError("No uid provided", self::ERROR_TYPE_GENERAL);
$result = $this->MitarbeiterModel->isMitarbeiter($uid);
if (isError($result)) {
$this->terminateWithError("error when calling Mitarbeiter_model function isMitarbeiter with uid " . $uid, self::ERROR_TYPE_GENERAL);
}
$result = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($result);
}
// -----------------------------------------------------------------------------------------------------------------
// Private methods
/**
* gets the identifier, phrase, and url for each calendar sync option
* @access private
* @return array array of arrays, where each child array is a sync option
*/
private function getCalendarSyncUrlData()
{
return [
[
"identifier" => "cal_dav",
"labelPhrase" => "profil/calendar_sync_cal_dav",
"url" => APP_ROOT . "webdav/lvplan.php/calendars/" . $this->uid . "/LVPlan-" . $this->uid,
],
[
"identifier" => "cal_dav_principal",
"labelPhrase" => "profil/calendar_sync_cal_dav_principal",
"url" => APP_ROOT . "webdav/lvplan.php/principals/" . $this->uid,
],
[
"identifier" => "i_cal",
"labelPhrase" => "profil/calendar_sync_i_cal",
"url" => APP_ROOT . "webdav/google.php?cal=" . encryptData($this->uid, LVPLAN_CYPHER_KEY) . "&" . microtime(true),
],
];
}
}
@@ -136,7 +136,7 @@ class ProfilUpdate extends FHCAPI_Controller
$this->uid == $profil_update->uid
) {
// Get file to be downloaded from DMS
$download = $this->dmslib->download($dms_id);
$download = $this->dmslib->getOutputFileInfo($dms_id);
$download = $this->getDataOrTerminateWithError($download);
// Download file
$this->outputFile($download);
@@ -456,24 +456,28 @@ class ProfilUpdate extends FHCAPI_Controller
$_FILES['files']['error'] = $files['error'][$i];
$_FILES['files']['size'] = $files['size'][$i];
$dms = [
"kategorie_kurzbz" => "profil_aenderung",
"version" => 0,
"name" => $_FILES['files']['name'],
"mimetype" => $_FILES['files']['type'],
"beschreibung" => $this->uid . " Profil Änderung",
"insertvon" => $this->uid,
"insertamum" => "NOW()",
];
// File upload
$uploadDataResult = $this->uploadFile('files', array('jpg', 'png', 'pdf'));
if (isError($uploadDataResult)) $this->addError(getError($uploadDataResult));
if (!hasData($uploadDataResult)) $this->addError('Upload failed');
$tmp_res = $this->dmslib->upload($dms, 'files', array("jpg", "png", "pdf"));
if(isError($tmp_res)){
$this->addError(getError($tmp_res));
if (hasData($uploadDataResult))
{
// Add file to the DMS (DB + file system)
$dms_res = $this->dmslib->add(
getData($uploadDataResult)['file_name'],
getData($uploadDataResult)['file_type'],
fopen(getData($uploadDataResult)['full_path'], 'r'),
'profil_aenderung', // kategorie_kurzbz
null, // dokument_kurzbz
null, // beschreibung
false, // cis_suche
null, // schlagworte
getAuthUID() // insertvon
);
$dms_res = $this->getDataOrTerminateWithError($dms_res);
array_push($res, $dms_res);
}
$tmp_res = $this->getDataOrTerminateWithError($tmp_res);
array_push($res, $tmp_res);
}
$this->terminateWithSuccess($res);
@@ -1,64 +0,0 @@
<?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 StgOrgLvPlan extends FHCAPI_Controller
{
/**
* Object initialization
*/
public function __construct()
{
parent::__construct([
'stgOrgLvPlanViewData' => self::PERM_LOGGED,
]);
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* fetches view data for stg org lv plan
* @access public
*/
public function stgOrgLvPlanViewData()
{
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
$this->StudiengangModel->addOrder('typ');
$this->StudiengangModel->addOrder('kurzbz');
$result = $this->StudiengangModel->loadWhere([
'aktiv' => true
]);
$studiengaenge = $this->getDataOrTerminateWithError($result);
$viewData = array(
'studiengaenge' => $studiengaenge,
);
$this->terminateWithSuccess($viewData);
}
// -----------------------------------------------------------------------------------------------------------------
// Private methods
}
@@ -1,67 +0,0 @@
<?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 Studiensemester extends FHCAPI_Controller
{
private $_ci;
/**
* Object initialization
*/
public function __construct()
{
parent::__construct([
'getStudiensemester'=> self::PERM_LOGGED,
]);
$this->_ci =& get_instance();
$this->_ci->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* GET METHOD
* returns List of all studiensemester as well as current one
*/
public function getStudiensemester()
{
$this->_ci->StudiensemesterModel->addOrder("start", "DESC");
$result = $this->_ci->StudiensemesterModel->load();
$studiensemester = getData($result);
$result = $this->_ci->StudiensemesterModel->getAkt();
$aktuell = getData($result);
$this->terminateWithSuccess(array($studiensemester, $aktuell));
}
//------------------------------------------------------------------------------------------------------------------
// Private methods
}
@@ -62,36 +62,21 @@ class Studium extends FHCAPI_Controller
if($this->getDataOrTerminateWithError($this->StudentModel->isStudent(getAuthUID()))){
$studentLehrverband =$this->StudentlehrverbandModel->loadWhere(["student_uid" => getAuthUID(), "studiensemester_kurzbz" => $aktuelles_studiensemester->studiensemester_kurzbz]);
//TODO(Manu) check if use Fallback or just comment out all paramschecks?
//add Fallback: if no LehrverbandData of actual semester, get Data of previous one
if(!hasData($studentLehrverband))
{
$result= $this->StudiensemesterModel->getPreviousFrom($aktuelles_studiensemester->studiensemester_kurzbz);
$data = $this->getDataOrTerminateWithError($result);
$vorheriges_studiensemester = current($data)->studiensemester_kurzbz;
$studentLehrverband =$this->StudentlehrverbandModel->loadWhere(["student_uid" => getAuthUID(), "studiensemester_kurzbz" => $vorheriges_studiensemester]);
}
$studentLehrverband = current(getData($studentLehrverband));
$studentLehrverband = current($this->getDataOrTerminateWithError($studentLehrverband));
$student_studiensemester = $studentLehrverband->studiensemester_kurzbz;
$student_studiengang = $studentLehrverband->studiengang_kz;
$student_semester = $studentLehrverband->semester;
$student_studienplan = $this->getStudienPlanFromPrestudentStatus(getAuthPersonId())->studienplan_id;
if(!isset($parameter_studiensemester)) {
$student_studiensemester = $studentLehrverband->studiensemester_kurzbz;
$parameter_studiensemester = $student_studiensemester;
}
if(!isset($parameter_studiengang)) {
$student_studiengang = $studentLehrverband->studiengang_kz;
$parameter_studiengang = $student_studiengang;
}
if(!isset($parameter_semester)) {
$student_semester = $studentLehrverband->semester;
$parameter_semester = $student_semester;
}
if(!isset($parameter_studiensemester))
$parameter_studiensemester = $student_studiensemester;
if(!isset($parameter_studiengang))
$parameter_studiengang = $student_studiengang;
if(!isset($parameter_semester))
$parameter_semester = $student_semester;
if(!isset($parameter_studienplan))
$parameter_studienplan = $student_studienplan;
$parameter_studienplan = $student_studienplan;
}
if(isset($parameter_studiensemester)){
@@ -111,7 +96,8 @@ class Studium extends FHCAPI_Controller
// fetch studiensemester
$allStudienSemester = $this->getDataOrTerminateWithError($this->StudiensemesterModel->load());
if(isset($parameter_studiensemester) && !empty(array_filter($allStudienSemester, function($studiensemester) use($parameter_studiensemester){
return $studiensemester->studiensemester_kurzbz == $parameter_studiensemester->studiensemester_kurzbz;
}))){
@@ -230,8 +216,6 @@ class Studium extends FHCAPI_Controller
$studienplaene = array_map(function($studienplan){
$orgform = current($this->getDataOrTerminateWithError($this->OrgformModel->loadWhere(["orgform_kurzbz" => $studienplan->orgform_kurzbz])));
$studienplan->orgform_bezeichnung = $orgform->bezeichnung;
// bezeichnung_mehrsprachig
$studienplan->orgform_bezeichnung_english = $orgform->bezeichnung_mehrsprachig[1];
return $studienplan;
},$studienplaene);
return $studienplaene;
@@ -1,367 +0,0 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
class Zeitsperren extends FHCAPI_Controller
{
public function __construct()
{
parent::__construct([
'getZeitsperrenUser' => self::PERM_LOGGED,
'getTypenZeitsperren' => self::PERM_LOGGED,
'getTypenErreichbarkeit' => self::PERM_LOGGED,
'getStunden' => self::PERM_LOGGED,
'loadZeitsperre' => self::PERM_LOGGED,
'add' => self::PERM_LOGGED,
'update' => self::PERM_LOGGED,
'delete' => self::PERM_LOGGED,
]);
// Load Libraries
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
$this->load->library('form_validation');
// Load language phrases
$this->loadPhrases([
'ui',
'person',
'zeitsperren'
]);
// Load models
$this->load->model('ressource/Zeitsperre_model', 'ZeitsperreModel');
$this->load->model('ressource/Zeitsperretyp_model', 'ZeitsperretypModel');
$this->load->model('ressource/Erreichbarkeit_model', 'ErreichbarkeitModel');
$this->load->model('ressource/Stunde_model', 'StundeModel');
$this->load->model('ressource/Zeitaufzeichnung_model', 'ZeitaufzeichnungModel');
}
public function getZeitsperrenUser($uid)
{
//check if $uid is passedUser
$loggedInUser = getAuthUID();
if($loggedInUser != $uid) {
$this->load->library('PermissionLib');
$isAdmin = $this->permissionlib->isBerechtigt('admin');
if(!$isAdmin) {
$this->terminateWithError($this->p->t('ui', 'noAdmin'), self::ERROR_TYPE_GENERAL);
}
}
$result = $this->ZeitsperreModel->getZeitsperrenUser($uid);
if (isError($result)) {
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess((getData($result) ?: []));
}
public function getTypenZeitsperren()
{
$this->ZeitsperretypModel->addOrder('beschreibung', 'ASC');
$result = $this->ZeitsperretypModel->load();
if (isError($result)) {
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess((getData($result) ?: []));
}
public function getTypenErreichbarkeit()
{
$result = $this->ErreichbarkeitModel->load();
if (isError($result)) {
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess((getData($result) ?: []));
}
public function getStunden()
{
$this->StundeModel->addOrder('stunde', 'ASC');
$result = $this->StundeModel->load();
if (isError($result)) {
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess((getData($result) ?: []));
}
public function loadZeitsperre($zeitsperre_id)
{
$this->ZeitsperreModel->addSelect(
'campus.tbl_zeitsperre.*, typ.*,
ma.person_id AS ma_person_id, ma.vorname AS ma_vorname, ma.nachname AS ma_nachname,
ma.titelpre AS ma_titelpre, ma.titelpost AS ma_titelpost'
);
$this->ZeitsperreModel->addJoin('campus.tbl_zeitsperretyp typ', 'ON (typ.zeitsperretyp_kurzbz = campus.tbl_zeitsperre.zeitsperretyp_kurzbz)');
$this->ZeitsperreModel->addJoin('public.tbl_benutzer ben', 'ON (ben.uid = campus.tbl_zeitsperre.vertretung_uid)', 'LEFT');
$this->ZeitsperreModel->addJoin('public.tbl_person ma', 'ON (ma.person_id = ben.person_id)', 'LEFT');
$result = $this->ZeitsperreModel->loadWhere(
array('zeitsperre_id' => $zeitsperre_id)
);
if (isError($result)) {
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess((current(getData($result)) ?: []));
}
public function add($mitarbeiter_uid)
{
$loggedInUser = getAuthUID();
if($mitarbeiter_uid != $loggedInUser)
$this->terminateWithError($this->p->t('ui', 'noPermission'), self::ERROR_TYPE_GENERAL);
$this->form_validation->set_rules('zeitsperretyp_kurzbz', 'Grund Zeitsperre', 'required', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Grund Zeitsperre'])
]);
$this->form_validation->set_rules('vondatum', 'VonDatum', 'required|is_valid_date', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'VonDatum']),
'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'VonDatum'])
]);
$this->form_validation->set_rules('bisdatum', 'BisDatum', 'required|is_valid_date|callback_check_von_bis_datum|callback_check_diff_intval', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'BisDatum']),
'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field' => 'BisDatum']),
'check_von_bis_datum' => $this->p->t('zeitsperre', 'error_VonDatumGroesserAlsBisDatum'),
'check_diff_intval' => $this->p->t('zeitsperre', 'error_zeitraumAuffallendHoch')
]);
if ($this->form_validation->run() == false)
{
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$bezeichnung = $this->input->post('bezeichnung');
$vondatum = $this->input->post('vondatum');
$vonstunde = $this->input->post('vonstunde');
$bisdatum = $this->input->post('bisdatum');
$bisstunde = $this->input->post('bisstunde');
//$vonIso = $this->input->post('vonISO'); //Timestamp für Stunde
//$bisIso = $this->input->post('bisISO'); //Timestamp für Stunde
$erreichbarkeit_kurzbz = $this->input->post('erreichbarkeit_kurzbz');
$vertretung_uid = $this->input->post('vertretung_uid');
$zeitsperretyp_kurzbz = $this->input->post('zeitsperretyp_kurzbz');
//check if existing zeitsperre
$result = $this->ZeitsperreModel->getSperreByDate($mitarbeiter_uid, $vondatum, $vonstunde, true);
$data = $this->getDataOrTerminateWithError($result);
if(hasData($result))
{
$this->terminateWithError($this->p->t('zeitsperren', 'error_existingZeitsperre', ['typ'=> current($data)->zeitsperretyp_kurzbz]), self::ERROR_TYPE_GENERAL);
}
//check if existing zeitaufzeichnung
if(in_array($zeitsperretyp_kurzbz, Zeitsperre_model::BLOCKIERENDE_ZEITSPERREN))
{
$result = $this->ZeitsperreModel->existsZeitaufzeichnung($mitarbeiter_uid, $vondatum, $bisdatum);
if(hasData($result))
$this->terminateWithError($this->p->t('zeitsperren', 'error_existingZeitaufzeichnung'), self::ERROR_TYPE_GENERAL);
}
$result = $this->ZeitsperreModel->insert(
[
'mitarbeiter_uid' => $mitarbeiter_uid,
'bezeichnung' => $bezeichnung,
'vondatum' => $vondatum,
'vonstunde' => $vonstunde,
'bisdatum' => $bisdatum,
'bisstunde' => $bisstunde,
'erreichbarkeit_kurzbz' => $erreichbarkeit_kurzbz,
'zeitsperretyp_kurzbz' => $zeitsperretyp_kurzbz,
'vertretung_uid' => $vertretung_uid,
'insertvon' => $loggedInUser,
'insertamum' => date('c'),
]
);
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
public function update($zeitsperre_id)
{
//check if loggedin User is owner of the zeitsperre
$loggedInUser = getAuthUID();
$result = $this->ZeitsperreModel->load($zeitsperre_id);
$data = $this->getDataOrTerminateWithError($result);
$uid = current($data)->mitarbeiter_uid;
if($uid != $loggedInUser)
$this->terminateWithError($this->p->t('ui', 'noPermission'), self::ERROR_TYPE_GENERAL);
if(!$zeitsperre_id)
{
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Zeitsperre_id']), self::ERROR_TYPE_GENERAL);
}
//get current params
$array_update = [
'bezeichnung',
'vondatum',
'vonstunde',
'bisdatum',
'bisstunde',
// 'vonISO', //Timestamp für Stunde
// 'bisISO', //Timestamp für Stunde
'erreichbarkeit_kurzbz',
'vertretung_uid',
'zeitsperretyp_kurzbz',
'mitarbeiter_uid',
];
$post = $this->input->post();
$update = [];
foreach ($array_update as $prop)
{
if (array_key_exists($prop, $post))
{
$update[$prop] = $post[$prop];
}
}
// Validation
$rulesDefined = false; //necessary, otherwise CI validation will always be triggered, even without rules
foreach ($update as $key => $val) {
switch ($key) {
case 'zeitsperretyp_kurzbz':
$this->form_validation->set_rules(
$key,
'Grund Zeitsperre',
'required',
['required' => $this->p->t('ui', 'error_fieldRequired', ['field'=>'Grund Zeitsperre'])]
);
$rulesDefined = true;
break;
case 'vondatum':
$this->form_validation->set_rules(
$key,
'VonDatum',
'required|is_valid_date',
[
'required' => $this->p->t('ui', 'error_fieldRequired', ['field'=>'VonDatum']),
'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field'=>'VonDatum'])
]
);
$rulesDefined = true;
break;
case 'bisdatum':
$rules = 'required|is_valid_date';
if (array_key_exists('vondatum', $update)) {
$rules .= '|callback_check_von_bis_datum|callback_check_diff_intval';
}
$this->form_validation->set_rules(
$key,
'BisDatum',
$rules,
[
'required' => $this->p->t('ui', 'error_fieldRequired', ['field'=>'BisDatum']),
'is_valid_date' => $this->p->t('ui', 'error_notValidDate', ['field'=>'BisDatum']),
'check_von_bis_datum' => $this->p->t('zeitsperre', 'error_VonDatumGroesserAlsBisDatum'),
'check_diff_intval' => $this->p->t('zeitsperre', 'error_zeitraumAuffallendHoch')
]
);
$rulesDefined = true;
break;
}
}
if ($rulesDefined && $this->form_validation->run() == false) {
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
if(array_key_exists('vondatum', $post) || array_key_exists('bisdatum', $post))
{
$result = $this->ZeitsperreModel->load($zeitsperre_id);
$data = $this->getDataOrTerminateWithError($result);
$data = current($data);
$mitarbeiter_uid = array_key_exists('mitarbeiter_uid', $post) ? $update['mitarbeiter_uid'] : $data->mitarbeiter_uid;
$vondatum = array_key_exists('vondatum', $post) ? $update['vondatum'] : $data->vondatum;
$bisdatum = array_key_exists('bisdatum', $post) ? $update['bisdatum'] : $data->bisdatum;
$vonstunde = array_key_exists('vonstunde', $post) ? $update['vonstunde'] : $data->vonstunde;
$zeitsperretyp_kurzbz = array_key_exists('zeitsperretyp_kurzbz', $post) ? $update['zeitsperretyp_kurzbz'] : $data->zeitsperretyp_kurzbz;
$result = $this->ZeitsperreModel->getSperreByDate($mitarbeiter_uid, $vondatum, $vonstunde, true);
$data = $this->getDataOrTerminateWithError($result);
if(hasData($result))
{
$this->terminateWithError($this->p->t('zeitsperren', 'error_existingZeitsperre', ['typ'=> current($data)->zeitsperretyp_kurzbz]), self::ERROR_TYPE_GENERAL);
}
//check if existing zeitaufzeichnung
if(in_array($zeitsperretyp_kurzbz, Zeitsperre_model::BLOCKIERENDE_ZEITSPERREN))
{
$result = $this->ZeitsperreModel->existsZeitaufzeichnung($mitarbeiter_uid, $vondatum, $bisdatum);
if(hasData($result))
$this->terminateWithError($this->p->t('zeitsperren', 'error_existingZeitaufzeichnung'), self::ERROR_TYPE_GENERAL);
}
}
if (!empty($update)) {
$update['updatevon'] = $loggedInUser;
$update['updateamum'] = date('c');
$result = $this->ZeitsperreModel->update($zeitsperre_id, $update);
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
else
$this->terminateWithSuccess("no update");
}
public function delete($zeitsperre_id)
{
if (!is_numeric($zeitsperre_id) || (int)$zeitsperre_id <= 0)
{
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Zeitsperre_id']), self::ERROR_TYPE_GENERAL);
}
//check if loggedin User is owner of the zeitsperre
$loggedInUser = getAuthUID();
$result = $this->ZeitsperreModel->load($zeitsperre_id);
$data = $this->getDataOrTerminateWithError($result);
$uid = current($data)->mitarbeiter_uid;
if($uid != $loggedInUser)
$this->terminateWithError($this->p->t('ui', 'noPermission'), self::ERROR_TYPE_GENERAL);
$result = $this->ZeitsperreModel->delete(
array('zeitsperre_id' => $zeitsperre_id)
);
if (isError($result)) {
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess((getData($result) ?: []));
}
public function check_von_bis_datum($bisdatum)
{
$vondatum = $this->input->post('vondatum');
return $vondatum <= $bisdatum;
}
public function check_diff_intval($bisdatum)
{
$vondatum = $this->input->post('vondatum');
// Intervall in days
$vonTs = strtotime($vondatum);
$bisTs = strtotime($bisdatum);
$tage = ($bisTs - $vonTs) / 86400;
// if intervall > 14
return $tage <= 14;
}
}
@@ -1,232 +0,0 @@
<?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 RoomPlan extends FHCAPI_Controller
{
/**
* Object initialization
*/
public function __construct()
{
parent::__construct([
'addRoomReservation' => self::PERM_LOGGED,
'deleteRoomReservation' => self::PERM_LOGGED,
'getRoomCreationInfo' => self::PERM_LOGGED,
'getGruppen' => self::PERM_LOGGED,
'getLektor' => self::PERM_LOGGED,
'getReservableMap' => self::PERM_LOGGED,
]);
$this->load->library('LogLib');
$this->loglib->setConfigs(array(
'classIndex' => 5,
'functionIndex' => 5,
'lineIndex' => 4,
'dbLogType' => 'API',
'dbExecuteUser' => 'RESTful API'
));
$this->load->library('form_validation');
$this->load->library('PermissionLib');
$this->load->library('StundenplanLib');
$this->loadPhrases(['ui']);
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
public function addRoomReservation()
{
$this->form_validation->set_rules('selectedStart', "Start", "required");
$this->form_validation->set_rules('selectedEnd', "End", "required");
$this->form_validation->set_rules('title', "Title", "required|max_length[10]");
$this->form_validation->set_rules('beschreibung', "Beschreibung", "required|max_length[32]");
$this->form_validation->set_rules('ort_kurzbz', "Ort", "required|max_length[16]");
$this->form_validation->set_rules('studiengang', 'Studiengang', 'numeric');
$this->form_validation->set_rules('semester', 'Semester', 'integer|greater_than_equal_to[0]');
$this->form_validation->set_rules('verband', 'Verband', 'trim');
$this->form_validation->set_rules('gruppe', 'Gruppe', 'trim');
$this->form_validation->set_rules('spezialgruppe', 'Spezialgruppe', 'max_length[32]');
$this->form_validation->set_rules('lektoren', 'Lektoren');
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
$start = $this->input->post('selectedStart');
$end = $this->input->post('selectedEnd');
$title = $this->input->post('title');
$beschreibung = $this->input->post('beschreibung');
$ort_kurzbz = $this->input->post('ort_kurzbz');
$studiengang_kz = $this->input->post('studiengang');
$semester = $this->input->post('semester');
$verband = $this->input->post('verband');
$gruppe = $this->input->post('gruppe');
$spezialgruppe = $this->input->post('spezialgruppe');
$lektoren = $this->input->post('lektoren');
$result = $this->stundenplanlib->addReservation($start, $end, $title, $beschreibung, $ort_kurzbz, $lektoren, $studiengang_kz, $semester, $verband, $gruppe, $spezialgruppe);
if (isError($result))
$this->terminateWithError($result);
$this->terminateWithSuccess($result);
}
public function deleteRoomReservation()
{
$reservierung_id = $this->input->post('reservierung_id');
$result = $this->stundenplanlib->deleteReservation($reservierung_id);
if (isError($result))
$this->terminateWithError($result);
$this->terminateWithSuccess($result);
}
public function getRoomCreationInfo()
{
$return_array = array('berechtigt' => false, 'studiengaenge' => []);
if (!$this->permissionlib->isBerechtigt('lehre/reservierung'))
$this->terminateWithSuccess($return_array);
$stg_berechtigungen = $this->permissionlib->getSTG_isEntitledFor('lehre/reservierung');
if (isEmptyArray($stg_berechtigungen))
$this->terminateWithSuccess($return_array);
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
$this->StudiengangModel->addSelect('studiengang_kz, UPPER(CONCAT(typ, kurzbz)) as kuerzel, kurzbzlang');
$this->StudiengangModel->addOrder('typ, kurzbz');
$this->StudiengangModel->db->where_in('studiengang_kz', $stg_berechtigungen);
$studiengaenge = $this->StudiengangModel->loadWhere(array('aktiv' => true));
if (isError($studiengaenge))
$this->terminateWithError($studiengaenge);
$return_array['studiengaenge'] = hasData($studiengaenge) ? getData($studiengaenge) : [];
$return_array['berechtigt'] = true;
$this->terminateWithSuccess($return_array);
}
public function getGruppen()
{
$query = $this->input->get('query');
if (is_null($query))
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
$stg_berechtigungen = $this->permissionlib->getSTG_isEntitledFor('lehre/reservierung');
if (isEmptyArray($stg_berechtigungen))
$this->terminateWithSuccess([]);
$this->load->model('organisation/gruppe_model', 'GruppeModel');
$query_words = explode(' ', urldecode($query));
$this->GruppeModel->addOrder('gruppe_kurzbz');
$this->GruppeModel->db->group_start();
foreach ($query_words as $word)
{
$this->GruppeModel->db->group_start();
$this->GruppeModel->db->where('gruppe_kurzbz ILIKE', "%" . $word . "%");
$this->GruppeModel->db->or_where('bezeichnung ILIKE', "%" . $word . "%");
$this->GruppeModel->db->or_where('beschreibung ILIKE', "%" . $word . "%");
$this->GruppeModel->db->or_where('orgform_kurzbz ILIKE', "%" . $word . "%");
if (is_numeric($word))
{
$this->GruppeModel->db->or_where('studiengang_kz', $word);
}
$this->GruppeModel->db->group_end();
}
$this->GruppeModel->db->group_end();
$this->GruppeModel->db->where_in('studiengang_kz', $stg_berechtigungen);
$gruppen = $this->GruppeModel->loadWhere(array('sichtbar' => true, 'lehre' => true));
if (isError($gruppen))
$this->terminateWithError($gruppen);
$this->terminateWithSuccess(hasData($gruppen) ? getData($gruppen) : []);
}
public function getLektor()
{
$query = $this->input->get('query');
if (is_null($query))
$this->terminateWithError($this->p->t('ui', 'ungueltigeParameter'), self::ERROR_TYPE_GENERAL);
$stg_berechtigungen = $this->permissionlib->getSTG_isEntitledFor('lehre/reservierung');
if (isEmptyArray($stg_berechtigungen))
$this->terminateWithSuccess([]);
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
$query_words = explode(' ', urldecode($query));
$this->MitarbeiterModel->addSelect('uid, person_id, vorname, nachname');
$this->MitarbeiterModel->addJoin('public.tbl_benutzer', 'uid = mitarbeiter_uid');
$this->MitarbeiterModel->addJoin('public.tbl_person', 'person_id');
$this->MitarbeiterModel->db->where('public.tbl_benutzer.aktiv', true);
$this->MitarbeiterModel->db->group_start();
foreach ($query_words as $word)
{
$this->MitarbeiterModel->db->group_start();
$this->MitarbeiterModel->db->where('tbl_person.vorname ILIKE', "%" . $word . "%");
$this->MitarbeiterModel->db->or_where('tbl_person.nachname ILIKE', "%" . $word . "%");
$this->MitarbeiterModel->db->or_where('uid ILIKE', "%" . $word . "%");
$this->MitarbeiterModel->db->group_end();
}
$this->MitarbeiterModel->db->group_end();
$this->MitarbeiterModel->addOrder('nachname');
$this->MitarbeiterModel->addOrder('vorname');
$mitarbeiter = $this->MitarbeiterModel->load();
if (isError($mitarbeiter))
$this->terminateWithError($mitarbeiter);
$this->terminateWithSuccess(hasData($mitarbeiter) ? getData($mitarbeiter) : []);
}
public function getReservableMap($ort_kurzbz = null)
{
$this->form_validation->set_rules('start_date', "StartDate", "required");
$this->form_validation->set_rules('end_date', "EndDate", "required");
if (!$this->form_validation->run())
$this->terminateWithValidationErrors($this->form_validation->error_array());
// storing the post parameter in local variables
$start_date = $this->input->post('start_date', true);
$end_date = $this->input->post('end_date', true);
$result = $this->stundenplanlib->getReservableMap($ort_kurzbz, $start_date, $end_date);
$this->terminateWithSuccess(array('reservierbarMap' => hasData($result) ? getData($result) : []));
}
}
@@ -40,32 +40,11 @@ class Board extends FHCAPI_Controller
public function list()
{
$this->DashboardModel->addSelect('dashboard_id');
$this->DashboardModel->addSelect('dashboard_kurzbz');
$this->DashboardModel->addSelect('tbl_dashboard.beschreibung');
$this->DashboardModel->addSelect("(
SELECT json_agg(w.*)
FROM dashboard.tbl_widget w
JOIN dashboard.tbl_dashboard_widget dw
USING(widget_id)
WHERE dw.dashboard_id=tbl_dashboard.dashboard_id
) AS \"widgetSetup\"");
$result = $this->DashboardModel->load();
$data = $this->getDataOrTerminateWithError($result);
$data = array_map(function ($dashboard) {
$tmpSetups = json_decode($dashboard->widgetSetup);
$tmpSetups = array_map(function ($widget) {
$widget->setup->file = absoluteJsImportUrl($widget->setup->file);
return $widget;
}, $tmpSetups);
$dashboard->widgetSetup = $tmpSetups;
return $dashboard;
}, $data);
$this->terminateWithSuccess($data);
$this->terminateWithSuccess($result);
}
public function create()
@@ -103,7 +82,7 @@ class Board extends FHCAPI_Controller
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
$this->terminateWithSuccess($result);
}
public function delete()
@@ -137,6 +116,6 @@ class Board extends FHCAPI_Controller
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
$this->terminateWithSuccess($result);
}
}
@@ -120,7 +120,10 @@ class Preset extends FHCAPI_Controller
$conf = $this->dashboardlib->getPreset($db, $funktion);
if ($conf) {
$preset = json_decode($conf->preset, true);
$result[$funktion] = $preset;
if (!isset($preset[$funktion]) || !isset($preset[$funktion]['widgets']))
$result[$funktion] = [];
else
$result[$funktion] = $preset[$funktion]['widgets'];
} else {
$result[$funktion] = [];
}
@@ -151,7 +154,7 @@ class Preset extends FHCAPI_Controller
$preset_decoded = json_decode($preset->preset, true);
$preset_decoded[$widget['widgetid']] = $widget;
$this->dashboardlib->addWidgetsToWidgets($preset_decoded, $dashboard_kurzbz, $funktion_kurzbz, [$widget]);
$preset->preset = json_encode($preset_decoded);
@@ -183,10 +186,8 @@ class Preset extends FHCAPI_Controller
$preset_decoded = json_decode($preset->preset, true);
if (!isset($preset_decoded[$widgetid]))
if (!$this->dashboardlib->removeWidgetFromWidgets($preset_decoded, $funktion_kurzbz, $widgetid))
show_404();
unset($preset_decoded[$widgetid]);
$preset->preset = json_encode($preset_decoded);
@@ -48,9 +48,25 @@ class User extends FHCAPI_Controller
$uid = $this->authlib->getAuthObj()->username;
$mergedconfig = $this->dashboardlib->getMergedUserConfig($dashboard->dashboard_id, $uid);
/*$mergedconfig = $this->dashboardlib->getMergedConfig($dashboard->dashboard_id, $uid);
$this->terminateWithSuccess($mergedconfig);
$this->terminateWithSuccess([
'general' => call_user_func_array(
'array_merge_recursive',
$mergedconfig
)
]);*/
$defaultconfig = $this->dashboardlib->getDefaultConfig($dashboard->dashboard_id);
$userconfig = $this->dashboardlib->getUserConfig($dashboard->dashboard_id, $uid);
$defaultconfig_squashed = $defaultconfig ? call_user_func_array('array_replace_recursive', $defaultconfig) : [];
$userconfig_squashed = $userconfig ? call_user_func_array('array_replace_recursive', $userconfig) : [];
$mergedconfig = array_replace_recursive($defaultconfig_squashed, $userconfig_squashed);
$this->terminateWithSuccess([
DashboardLib::SECTION_IF_FUNKTION_KURZBZ_IS_NULL => $mergedconfig
]);
}
public function addWidget()
@@ -70,15 +86,26 @@ class User extends FHCAPI_Controller
if (!isset($widget['widgetid']))
$widget['widgetid'] = $this->dashboardlib->generateWidgetId($dashboard_kurzbz);
if (isset($widget['source']))
unset($widget['source']);
$override = $this->dashboardlib->getOverrideOrCreateEmptyOverride($dashboard_kurzbz, $uid);
$override_decoded = json_decode($override->override, true);
$override_decoded[$widget['widgetid']] = $widget;
if (!isset($override_decoded['general']) || !is_array($override_decoded['general']))
$override_decoded['general'] = [];
if (!isset($override_decoded['general']['widgets']))
$override_decoded['general']['widgets'] = [];
$override_decoded['general']['widgets'][$widget['widgetid']] = $widget;
// NOTE(chris): remove doubles in other funktionen
foreach ($override_decoded as $funktion => $array) {
if ($funktion == 'general')
continue;
if (isset($array['widgets']) && isset($array['widgets'][$widget['widgetid']]))
unset($override_decoded[$funktion]['widgets'][$widget['widgetid']]);
}
$override->override = json_encode($override_decoded);
$result = $this->dashboardlib->insertOrUpdateOverride($override);
@@ -108,10 +135,18 @@ class User extends FHCAPI_Controller
$override_decoded = json_decode($override->override, true);
if (!isset($override_decoded[$widget_id]))
show_404();
unset($override_decoded[$widget_id]);
foreach (array_keys($override_decoded) as $k) {
if (!isset($override_decoded[$k]["widgets"])) {
unset($override_decoded[$k]);
continue;
}
if (isset($override_decoded[$k]["widgets"][$widget_id])) {
unset($override_decoded[$k]["widgets"][$widget_id]);
}
if (!$override_decoded[$k]["widgets"]) {
unset($override_decoded[$k]);
}
}
$override->override = json_encode($override_decoded);
@@ -9,10 +9,9 @@ class Detailheader extends FHCAPI_Controller
public function __construct()
{
parent::__construct([
'getHeader' => self::PERM_LOGGED,
'getPersonAbteilung' => self::PERM_LOGGED,
'getLeitungOrg' => self::PERM_LOGGED,
'getSemesterStati' => self::PERM_LOGGED,
'getHeader' => ['vertrag/mitarbeiter:r'],
'getPersonAbteilung' => ['vertrag/mitarbeiter:r'],
'getLeitungOrg' => ['vertrag/mitarbeiter:r'],
]);
}
@@ -49,17 +48,6 @@ class Detailheader extends FHCAPI_Controller
$this->terminateWithSuccess(current($data));
}
public function getSemesterStati($prestudent_id)
{
$this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
$result = $this->PrestudentstatusModel->getAllPrestudentstatiWithStudiensemester($prestudent_id);
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
}
}
@@ -1,218 +0,0 @@
<?php
/**
* FH-Complete
*
* @package FHC-API
* @author FHC-Team
* @copyright Copyright (c) 2016, fhcomplete.org
* @license GPLv3
* @link http://fhcomplete.org
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
if (!defined('BASEPATH')) exit('No direct script access allowed');
use CI3_Events as Events;
class PaabgabeUebersicht extends FHCAPI_Controller
{
const DOWNLOAD_PERMISSION = 'lehre/abgabetool:download';
const ABGABE_TYPES = ['Bachelor', 'Diplom'];
/**
* PaabgabeUebersicht API constructor.
*/
public function __construct()
{
parent::__construct([
'viewData' => self::PERM_LOGGED,
'getPaAbgaben' => array('lehre/abgabetool:r'),
'getStudiengaenge' => array('lehre/abgabetool:r'),
'getTermine' => array('lehre/abgabetool:r'),
'getPaAbgabetypen' => array('lehre/abgabetool:r'),
'downloadZip' => array('lehre/abgabetool:r'),
//'downloadProjektarbeit' => array('lehre/abgabetool:r')
]);
$this->load->model('education/Paabgabe_model', 'PaabgabeModel');
$this->load->library('PermissionLib');
// Load Phrases
$this->loadPhrases([
'abgabetool'
]);
}
public function viewData()
{
$viewData = [
"uid" => getAuthUID(),
// TODO create permission
"showEdit" => true,
];
$this->terminateWithSuccess($viewData);
}
/**
* Get Projektabgaben for search criteria.
*/
public function getPaAbgaben()
{
$studiengang_kz = $this->input->get('studiengang_kz');
$abgabetyp_kurzbz = $this->input->get('abgabetyp_kurzbz');
$abgabedatum = $this->input->get('abgabedatum');
$personSearchString = $this->input->get('personSearchString');
$result = $this->PaabgabeModel->getPaAbgaben(self::ABGABE_TYPES, $studiengang_kz, $abgabetyp_kurzbz, $abgabedatum, $personSearchString);
if (isError($result)) $this->terminateWithError(getError($result), self::ERROR_TYPE_DB);
// check wether Abgabe is in visual library
if (hasData($result))
{
Events::trigger('in_visual_library', getData($result));
}
$this->terminateWithSuccess(getData($result) ?: []);
}
/**
* Get all Studiengänge for which user is entitled for
*/
public function getStudiengaenge()
{
$studiengang_kz_arr = $this->permissionlib->getSTG_isEntitledFor(self::DOWNLOAD_PERMISSION);
if (!$studiengang_kz_arr) $this->terminateWithSuccess([]);
$this->load->model('organisation/Studiengang_model', 'StudiengangModel');
$this->StudiengangModel->addSelect('tbl_studiengang.*, UPPER(tbl_studiengang.typ || tbl_studiengang.kurzbz) AS kuerzel', $studiengang_kz_arr);
$this->StudiengangModel->db->where_in('studiengang_kz', $studiengang_kz_arr);
$this->StudiengangModel->addOrder('typ, kurzbz');
$result = $this->StudiengangModel->load();
if (isError($result)) $this->terminateWithError(getError($result), self::ERROR_TYPE_DB);
$this->terminateWithSuccess((getData($result) ?: []));
}
/**
* Get projekt work due dates, depending on search criteria.
*/
public function getTermine()
{
$studiengang_kz = $this->input->get('studiengang_kz');
$abgabetyp_kurzbz = $this->input->get('abgabetyp_kurzbz');
$result = $this->PaabgabeModel->getTermine(self::ABGABE_TYPES, $studiengang_kz, $abgabetyp_kurzbz);
if (isError($result)) $this->terminateWithError(getError($result), self::ERROR_TYPE_DB);
$this->terminateWithSuccess((getData($result) ?: []));
}
/**
* Get all submission types.
*/
public function getPaAbgabetypen()
{
// Load model PaabgabetypModel
$this->load->model('education/Paabgabetyp_model', 'PaabgabetypModel');
$this->PaabgabetypModel->addOrder('bezeichnung');
$result = $this->PaabgabetypModel->load();
if (isError($result)) $this->terminateWithError(getError($result), self::ERROR_TYPE_DB);
$this->terminateWithSuccess((getData($result) ?: []));
}
/**
* Download zip files with project works matching submission search criteria.
*/
public function downloadZip()
{
$studiengang_kz = $this->input->get('studiengang_kz');
$abgabetyp_kurzbz = $this->input->get('abgabetyp_kurzbz');
$abgabedatum = $this->input->get('abgabedatum');
$personSearchString = $this->input->get('personSearchString');
if (!isset($studiengang_kz) && !isset($abgabetyp_kurzbz) && !isset($abgabedatum) && !isset($personSearchString))
$this->terminateWithFileOutput('text/plain', $this->p->t('abgabetool', 'nichtsAusgewaehlt'));
$this->load->library('zip');
$result = $this->PaabgabeModel->getPaAbgaben(self::ABGABE_TYPES, $studiengang_kz, $abgabetyp_kurzbz, $abgabedatum, $personSearchString);
if (isError($result)) $this->terminateWithFileOutput('text/plain', getError($result));
$fileExists = false;
$studiengang_kuerzel = null;
if (!hasData($result)) $this->terminateWithFileOutput('text/plain', $this->p->t('abgabetool', 'keineDateienVorhanden'));
$abgaben = getData($result);
foreach ($abgaben as $abgabe)
{
$path = PAABGABE_PATH.$abgabe->paabgabe_id.'_'.$abgabe->uid.'.pdf';
if (file_exists($path))
{
$fileExists = true;
$studiengang_kuerzel = $abgabe->studiengang_kuerzel;
$this->zip->read_file($path);
}
}
if (!$fileExists) $this->terminateWithFileOutput('text/plain', $this->p->t('abgabetool', 'keineDateienVorhanden'));
$studiengang_kz = $this->input->get('studiengang_kz');
$zipFileName = 'Abgabe'.(isset($studiengang_kz) && isset($studiengang_kuerzel) ? '_'.$studiengang_kuerzel : '').'.zip';
$this->zip->download($zipFileName);
}
/**
* Download Projektarbeit document.
*/
//~ public function downloadProjektarbeit()
//~ {
//~ $paabgabe_id = $this->input->get('paabgabe_id');
//~ if (!is_numeric($paabgabe_id))
//~ $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id' => 'Abgabe ID']), self::ERROR_TYPE_GENERAL);
//~ //$abgabeRes = $this->PaabgabeModel->getEndabgabe($projektarbeit_id);
//~ $this->PaabgabeModel->addSelect("paabgabe_id, student_uid, tbl_paabgabe.datum, tbl_paabgabe.abgabedatum, projekttyp_kurzbz, titel, titel_english,
//~ paabgabe_id || '_' || student_uid || '.pdf' AS filename");
//~ $this->PaabgabeModel->addJoin('lehre.tbl_projektarbeit', 'projektarbeit_id');
//~ $abgabeRes = $this->PaabgabeModel->load($paabgabe_id);
//~ if (isError($abgabeRes))
//~ show_error(getError($abgabeRes));
//~ if (hasData($abgabeRes))
//~ {
//~ $endabgabe = getData($abgabeRes)[0];
//~ $filepath = PAABGABE_PATH.$endabgabe->filename;
//~ if (file_exists($filepath))
//~ {
//~ $this->output
//~ ->set_status_header(200)
//~ ->set_content_type('application/pdf', 'utf-8')
//~ ->set_header('Content-Disposition: attachment; filename="'.$endabgabe->filename.'"')
//~ ->set_output(file_get_contents($filepath))
//~ ->_display();
//~ }
//~ else
//~ {
//~ show_error("File does not exist.");
//~ }
//~ }
//~ }
}
@@ -158,19 +158,27 @@ class Unterbrechung extends FHCAPI_Controller
if (isset($_FILES['attachment']) && (!isset($_FILES['attachment']['error']) || $_FILES['attachment']['error'] != UPLOAD_ERR_NO_FILE)) {
$this->load->library('DmsLib');
$dms = $this->config->item('unterbrechung_dms');
if (!count(array_filter($dms, function ($v) {
return $v !== null;
})))
$dms = ['kategorie_kurzbz' => 'Akte'];
$dms['version'] = 0;
$allowed_filetypes = $this->config->item('unterbrechung_dms_filetypes') ?: ['*'];
$result = $this->dmslib->upload($dms, 'attachment', $allowed_filetypes);
$uploadDataResult = $this->uploadFile('attachment', $this->config->item('unterbrechung_dms_filetypes') ?: array('*'));
$data = $this->getDataOrTerminateWithError($result);
$dms_id = $data['dms_id'];
$data = $this->getDataOrTerminateWithError($uploadDataResult);
// Add file to the DMS (DB + file system)
$dms_res = $this->dmslib->add(
getData($uploadDataResult)['file_name'],
getData($uploadDataResult)['file_type'],
fopen(getData($uploadDataResult)['full_path'], 'r'),
'studierendenantrag',
null, // dokument_kurzbz
null, // beschreibung
false, // cis_suche
null, // schlagworte
getAuthUID() // insertvon
);
$dms_data = $this->getDataOrTerminateWithError($dms_res);
$dms_id = $dms_data->dms_id;
}
$result = $this->antraglib->createUnterbrechung($prestudent_id, $studiensemester, getAuthUID(), $grund, $datum_wiedereinstieg, $dms_id);
@@ -246,12 +246,12 @@ class Abschlusspruefung extends FHCAPI_Controller
{
$searchString = $this->input->get('searchString') ?? '';
$this->load->model('person/Person_model', 'PersonModel');
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
$result = $this->PersonModel->searchPerson($searchString, 'mitMaUid');
$result = $this->MitarbeiterModel->searchMitarbeiter($searchString, 'ohneMaUid');
if (isError($result)) {
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess($result ?: []);
@@ -32,8 +32,8 @@ class Akte extends Auth_Controller
'download' => ['admin:w', 'assistenz:w'],
]);
// Load models
$this->load->model('crm/Akte_model', 'AkteModel');
// Load libraries
$this->load->library('AkteLib');
}
//------------------------------------------------------------------------------------------------------------------
@@ -49,22 +49,22 @@ class Akte extends Auth_Controller
if (!is_numeric($akte_id)) $this->terminateWithError('akte Id missing');
$result = $this->AkteModel->load($akte_id);
$akteResult = $this->aktelib->getByAkteId($akte_id);
if (!hasData($result)) $this->terminateWithError('Akte not found');
if (!hasData($akteResult)) $this->terminateWithError('Akte not found');
$data = getData($result)[0];
$data = getData($akteResult)[0];
if (isset($data->inhalt) && $data->inhalt != '')
if (!isEmptyString($data->inhalt))
{
header('Content-Description: File Transfer');
header('Content-Type: '. $data->mimetype);
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Disposition: attachment; filename="'.$data->titel.'"');
echo base64_decode($data->inhalt);
die();
$fileObj = new stdClass();
$fileObj->file_content = base64_decode($data->inhalt);
$fileObj->name = $data->filename;
$fileObj->mimetype = $data->mimetype;
$fileObj->disposition = 'attachment';
$this->outputFile($fileObj);
}
}
}
@@ -46,6 +46,9 @@ class Archiv extends FHCAPI_Controller
$this->load->model('crm/Akte_model', 'AkteModel');
$this->load->model('system/Vorlage_model', 'VorlageModel');
// Load libraries
$this->load->library('AkteLib');
// Load language phrases
$this->loadPhrases([
'archiv'
@@ -57,7 +60,7 @@ class Archiv extends FHCAPI_Controller
/**
* Get archive documents for a person
* @return void
*/
public function getArchiv()
@@ -74,7 +77,11 @@ class Archiv extends FHCAPI_Controller
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$result = $this->AkteModel->getArchiv($person_id);
$result = $this->aktelib->getByPersonId(
$person_id,
null, // dokument_kurzbz
true // archiv
);
$data = $this->getDataOrTerminateWithError($result);
@@ -94,51 +101,6 @@ class Archiv extends FHCAPI_Controller
$this->terminateWithSuccess($data);
}
/**
*
* @param
* @return object success or error
*/
public function download()
{
$akte_id = $this->input->get('akte_id');
if (!is_numeric($akte_id)) $this->terminateWithError('akte Id missing');
$result = $this->AkteModel->load($akte_id);
if (!hasData($result)) $this->terminateWithError('Akte not found');
$data = getData($result)[0];
$fileObj = new stdClass();
if (isset($data->inhalt) && $data->inhalt != '')
{
// Define handle to output stream
$tmpFilePointer = fopen("php://output", 'w');
$meta_data = stream_get_meta_data($tmpFilePointer);
$filename = $meta_data["uri"];
fwrite($tmpFilePointer, $data->inhalt);
header('Content-Description: File Transfer');
header('Content-Type: '. $data->mimetype);
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
//header('Content-Length: ' . filesize($fileObj->file));
//header("Content-type: $data->mimetype");
header('Content-Disposition: attachment; filename="'.$data->titel.'"');
readfile($filename);
die();
}
else
{
$this->load->library('AkteLib');
$result = $this->aktelib->get($akte_id);
}
}
/**
* Updating an Akte
* @return void
@@ -193,7 +155,7 @@ class Archiv extends FHCAPI_Controller
$this->addMeta('content', base64_encode($content));
}
foreach ($allowed as $field)
if ($this->input->post($field) !== null)
$data[$field] = $this->input->post($field);
@@ -248,7 +210,7 @@ class Archiv extends FHCAPI_Controller
'akte_id' => $akte_id
]));
}
$result = $this->AkteModel->delete($akte_id);
if (isError($result)) $this->terminateWithError(getError($result));
@@ -27,7 +27,8 @@ class Dokumente extends FHCAPI_Controller
// Load Libraries
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
$this->load->library('form_validation');
$this->load->library('DmsLib', array('who' => getAuthUID()));
$this->load->library('AkteLib');
$this->load->library('DmsLib');
// Load language phrases
$this->loadPhrases([
@@ -78,32 +79,52 @@ class Dokumente extends FHCAPI_Controller
$this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Studiengang_kz']), self::ERROR_TYPE_GENERAL);
$resultPreDoc = $this->_getPrestudentDokumente($prestudent_id);
$arrayAccepted = [];
$person_id = $this->_getPersonId($prestudent_id);
$mergedArray = [];
$docNames = array_map(function ($item) {
return $item->dokument_kurzbz;
}, $resultPreDoc);
foreach ($resultPreDoc as $pre)
foreach($docNames as $doc)
{
$result = $this->AkteModel->getAktenFAS($person_id, $pre->dokument_kurzbz, $studiengang_kz, $prestudent_id, true);
$result = $this->AkteModel->getAktenFAS($person_id, $doc, $studiengang_kz, $prestudent_id, true);
if (isError($result))
{
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
if (hasData($result))
{
foreach (getData($result) as $doc)
$data = getData($result);
foreach ($data as $value)
{
$merged = clone $doc;
$merged->docdatum = $pre->docdatum;
$merged->insertvonma = $pre->insertvonma;
$merged->bezeichnung = $pre->bezeichnung;
$mergedArray[] = $merged;
array_push($arrayAccepted, $value);
}
}
else
{
$mergedArray[] = $pre;
}
//Mapping with document_kurzbz
$preDocMap = [];
foreach ($resultPreDoc as $pre) {
$preDocMap[$pre->dokument_kurzbz] = $pre;
}
$mergedArray = [];
foreach ($arrayAccepted as $doc) {
$merged = clone $doc;
if (isset($preDocMap[$doc->dokument_kurzbz])) {
$merged->docdatum = $preDocMap[$doc->dokument_kurzbz]->docdatum;
$merged->insertvonma = $preDocMap[$doc->dokument_kurzbz]->insertvonma;
$merged->bezeichnung = $preDocMap[$doc->dokument_kurzbz]->bezeichnung;
} else {
$merged->akzeptiertdatum = null;
$merged->akzeptiertvon = null;
}
$mergedArray[] = $merged;
}
$this->terminateWithSuccess($mergedArray);
@@ -170,8 +191,6 @@ class Dokumente extends FHCAPI_Controller
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
$uid = getAuthUID();
$result = $this->AkteModel->update(
[
'akte_id' => $this->input->post('akte_id'),
@@ -182,7 +201,7 @@ class Dokumente extends FHCAPI_Controller
'titel_intern' => $this->input->post('titel_intern'),
'nachgereicht_am' => $this->input->post('nachgereicht_am'),
'updateamum' => date('c'),
'updatevon' => $uid,
'updatevon' => getAuthUID(),
]
);
@@ -199,8 +218,6 @@ class Dokumente extends FHCAPI_Controller
if(!$dokument_kurzbz)
$this->terminateWithError($this->p->t('ui', 'errorMissingValue', ['value' => 'Dokument_kurzbz']), self::ERROR_TYPE_GENERAL);
$uid = getAuthUid();
//check if more than 1 dokumentkurzbz
//if()
@@ -208,10 +225,10 @@ class Dokumente extends FHCAPI_Controller
[
'prestudent_id' => $prestudent_id,
'dokument_kurzbz' => $dokument_kurzbz,
'mitarbeiter_uid' => $uid,
'mitarbeiter_uid' => getAuthUID(),
'datum' => date('c'),
'insertamum' => date('c'),
'insertvon' => $uid,
'insertvon' => getAuthUID(),
]
);
@@ -234,7 +251,6 @@ class Dokumente extends FHCAPI_Controller
$nachgereicht = current($dataAkte)->nachgereicht;
$inhalt = current($dataAkte)->inhalt;
$inhaltVorhanden = $inhalt != '';
$uid = getAuthUid();
$this->db->trans_start();
@@ -248,16 +264,15 @@ class Dokumente extends FHCAPI_Controller
$logdata_dms = "Logdata: " . var_export($logdata_dms, true);
//delete from dmsLib
$this->load->library('DmsLib');
$person_id = current($dataAkte)->person_id;
$result = $this->dmslib->delete($person_id, $dms_id);
$result = $this->aktelib->removeByPersonIdAndDmsId($person_id, $dms_id);
$this->getDataOrTerminateWithError($result);
//LOGGING Dms ID
$this->load->model('system/Log_model', 'LogModel');
$result = $this->LogModel->insert([
'executetime' => date('c'),
'mitarbeiter_uid' => $uid,
'mitarbeiter_uid' => getAuthUID(),
'beschreibung' => "Löschen der DMS_ID ". $dms_id,
'sql' => $logdata_dms
]);
@@ -274,7 +289,7 @@ class Dokumente extends FHCAPI_Controller
//Logging Deletion Akte
$result = $this->LogModel->insert([
'executetime' => date('c'),
'mitarbeiter_uid' => $uid,
'mitarbeiter_uid' => getAuthUID(),
'beschreibung' => "Löschen der Akte ". $akte_id,
'sql' => "DELETE FROM public.tbl_akte WHERE akte_id=" .$akte_id. " LogData: ". $logdata_akte
]);
@@ -293,7 +308,7 @@ class Dokumente extends FHCAPI_Controller
$result = $this->LogModel->insert([
'executetime' => date('c'),
'mitarbeiter_uid' => $uid,
'mitarbeiter_uid' => getAuthUID(),
'beschreibung' => "Löschen der Akte ". $akte_id,
'sql' => "DELETE FROM public.tbl_akte WHERE akte_id=" .$akte_id. " LogData: ". $logdata_akte
]);
@@ -308,7 +323,6 @@ class Dokumente extends FHCAPI_Controller
public function uploadDokument()
{
$this->load->library('DmsLib');
$prestudent_id = $this->input->post('prestudent_id');
$anmerkung_intern = $this->input->post('anmerkung_intern');
$titel_intern = $this->input->post('titel_intern');
@@ -331,34 +345,44 @@ class Dokumente extends FHCAPI_Controller
}
$this->db->trans_start();
$uid = getAuthUID();
$dms = array(
'kategorie_kurzbz' => 'Akte',
'version' => 0,
'name' => $_FILES['anhang']['name'],
'mimetype' => $_FILES['anhang']['type'],
'insertamum' => date('c'),
'insertvon' => $uid
);
$result = $this->dmslib->upload($dms, 'anhang', array("jpg", "png", "pdf"));
if (isError($result))
$uploadDataResult = $this->uploadFile('anhang', array('jpg', 'png', 'pdf'));
if (isError($uploadDataResult))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
return $this->terminateWithError(getError($uploadDataResult), self::ERROR_TYPE_GENERAL);
}
$dms_id = $result->retval['dms_id'];
// If data exists
if (hasData($uploadDataResult))
{
// Add file to the DMS (DB + file system)
$dms_res = $this->dmslib->add(
getData($uploadDataResult)['file_name'],
getData($uploadDataResult)['file_type'],
fopen(getData($uploadDataResult)['full_path'], 'r'),
'Akte', // kategorie_kurzbz
null, // dokument_kurzbz
null, // beschreibung
false, // cis_suche
null, // schlagworte
getAuthUID() // insertvon
);
}
// Error occurred or data not found
if (isError($dms_res) || !hasData($dms_res)) $this->terminateWithError(getError($dms_res), self::ERROR_TYPE_GENERAL);
$dms_id = getData($dms_res)->dms_id;
$person_id = $this->_getPersonId($prestudent_id);
$result = $this->DokumentModel->load($dokument_kurzbz);
$data = $this->getDataOrTerminateWithError($result);
$dokumentResult = $this->DokumentModel->load($dokument_kurzbz);
$data = $this->getDataOrTerminateWithError($dokumentResult);
$bezeichnung = current($data)->bezeichnung;
//save entry in akte
if($dms_id)
// Save entry in akte
if ($dms_id)
{
$result = $this->AkteModel->insert([
'person_id' => $person_id,
@@ -367,7 +391,7 @@ class Dokumente extends FHCAPI_Controller
'mimetype' => $_FILES['anhang']['type'],
'insertamum' => date('c'),
'erstelltam' => date('c'),
'insertvon' => $uid,
'insertvon' => getAuthUID(),
'anmerkung_intern' => $anmerkung_intern,
'titel_intern' => $titel_intern,
'bezeichnung' => $bezeichnung,
@@ -414,28 +438,26 @@ class Dokumente extends FHCAPI_Controller
$filecontentbase64 = $data->inhalt;
$filename = $data->titel;
if(intval($data->dms_id) > 0)
if (intval($data->dms_id) > 0)
{
$dmsdokres = $this->dmslib->read($data->dms_id);
if (!hasData($dmsdokres)) $this->terminateWithError('DMS File not found');
$dmsdok = getData($dmsdokres)[0];
$file = $this->dmslib->getOutputFileInfo($data->dms_id, $filename);
$mimetype = $dmsdok->mimetype;
$filecontentbase64 = $dmsdok->file_content;
$filename = $dmsdok->name;
$this->terminateWithFileOutput(getData($file)->mimetype, file_get_contents(getData($file)->file), $filename);
}
else
{
$filecontent = '';
$filecontent = '';
if (!empty($filecontentbase64)) {
$filecontent = base64_decode($filecontentbase64, true);
if (!empty($filecontentbase64)) {
$filecontent = base64_decode($filecontentbase64, true);
if ($filecontent === false) {
$this->terminateWithError('Base64-Dekodierung failed.');
if ($filecontent === false) {
$this->terminateWithError('Base64-Dekodierung failed.');
}
}
}
$this->terminateWithFileOutput($mimetype, $filecontent, $filename);
$this->terminateWithFileOutput($mimetype, $filecontent, $filename);
}
}
private function _getMissingDocuments($studiengang_kz, $prestudent_id)
@@ -751,10 +773,7 @@ class Dokumente extends FHCAPI_Controller
);
$data = $this->getDataOrTerminateWithError($result);
$student = current($data);
return $student->prestudent_id;
return hasData($data) ? getData($data)[0]->prestudent_id : null;
}
/**
@@ -48,8 +48,7 @@ class Konto extends FHCAPI_Controller
// Load language phrases
$this->loadPhrases([
'konto',
'lehre'
'konto'
]);
}
@@ -113,7 +112,7 @@ class Konto extends FHCAPI_Controller
*
* @return void
*/
public function getBuchungstypen($studiensemester_kurzbz = null)
public function getBuchungstypen()
{
$this->load->model('crm/Buchungstyp_model', 'BuchungstypModel');
@@ -123,7 +122,6 @@ class Konto extends FHCAPI_Controller
$data = $this->getDataOrTerminateWithError($result);
$this->_getOEHBeitrag($data, $studiensemester_kurzbz);
$this->terminateWithSuccess($data);
}
@@ -496,43 +494,4 @@ class Konto extends FHCAPI_Controller
$this->terminateWithSuccess();
}
private function _getOEHBeitrag(&$data, $studiensemester_kurzbz = null)
{
if (is_null($studiensemester_kurzbz))
{
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
$studiensemester_akt = $this->variablelib->getVar('semester_aktuell');
}
else
{
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
if ($this->StudiensemesterModel->isValidStudiensemester($studiensemester_kurzbz))
$studiensemester_akt = $studiensemester_kurzbz;
else
$this->terminateWithError($this->p->t('lehre', 'error_noStudiensemester'));
}
$this->load->model('codex/Oehbeitrag_model', 'OehbeitragModel');
$oehBeitrag = $this->OehbeitragModel->getByStudiensemester($studiensemester_akt);
$oehStandardbetrag = null;
if (hasData($oehBeitrag))
{
$oeh = getData($oehBeitrag)[0];
$summe = ($oeh->studierendenbeitrag + $oeh->versicherung) * -1;
$oehStandardbetrag = number_format((float)$summe, 2, '.', '');
}
if ($oehStandardbetrag !== null)
{
$data = array_map(function ($buchungstyp) use ($oehStandardbetrag) {
if (isset($buchungstyp->buchungstyp_kurzbz) && (strtolower($buchungstyp->buchungstyp_kurzbz) === 'oeh'))
{
$buchungstyp->standardbetrag = $oehStandardbetrag;
}
return $buchungstyp;
}, $data);
}
}
}
@@ -33,11 +33,6 @@ class Notiz extends Notiz_Controller
]);
}
/* public function getUid()
{
$this->terminateWithSuccess(getAuthUID());
}*/
public function getNotizen($id, $type)
{
@@ -59,317 +54,6 @@ class Notiz extends Notiz_Controller
}
/* public function loadNotiz()
{
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
$notiz_id = $this->input->post('notiz_id');
//$this->load->model('person/Notiz_model', 'NotizModel');
$this->NotizModel->addJoin('public.tbl_notiz_dokument', 'notiz_id', 'LEFT');
$this->NotizModel->addSelect('*');
$this->NotizModel->addSelect("TO_CHAR(CASE WHEN public.tbl_notiz.updateamum >= public.tbl_notiz.insertamum
THEN public.tbl_notiz.updateamum ELSE public.tbl_notiz.insertamum END::timestamp, 'DD.MM.YYYY HH24:MI:SS') AS lastUpdate");
$this->NotizModel->addLimit(1);
$result = $this->NotizModel->loadWhere(
array('notiz_id' => $notiz_id)
);
if (isError($result))
{
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
elseif (!hasData($result))
{
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL);
}
else
{
$this->terminateWithSuccess(current(getData($result)));
}
}
public function updateNotiz()
{
$this->load->library('form_validation');
$this->load->library('DmsLib');
if (isset($_POST['data']))
{
$data = json_decode($_POST['data']);
unset($_POST['data']);
foreach ($data as $k => $v) {
$_POST[$k] = $v;
}
}
$notiz_id = $this->input->post('notiz_id');
if(!$notiz_id)
{
$this->terminateWithError($this->p->t('ui','error_missingId',['id'=>'Notiz_id']), self::ERROR_TYPE_GENERAL);
}
//Form Validation
$this->form_validation->set_rules('titel', 'Titel', 'required', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel'])
]);
$this->form_validation->set_rules('text', 'Text', 'required', [
'required' => $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text'])
]);
if ($this->form_validation->run() == false)
{
$this->terminateWithValidationErrors($this->form_validation->error_array());
}
//update Notiz
$uid = getAuthUID();
$titel = $this->input->post('titel');
$text = $this->input->post('text');
$verfasser_uid = $this->input->post('verfasser');
$bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : $uid;
$erledigt = $this->input->post('erledigt');
$start = $this->input->post('start');
$ende = $this->input->post('ende');
$result = $this->NotizModel->update(
[
'notiz_id' => $notiz_id
],
[
'titel' => $titel,
'updatevon' => $uid,
'updateamum' => date('c'),
'text' => $text,
'verfasser_uid' => $verfasser_uid,
'bearbeiter_uid' => $bearbeiter_uid,
'start' => $start,
'ende' => $ende,
'erledigt' => $erledigt
]
);
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
//update(1) laden aller bereits mit dieser notiz_id verknüpften DMS-Einträge
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
$this->NotizdokumentModel->addJoin('campus.tbl_dms_version', 'dms_id');
$dms_uploaded = null;
$result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id));
if (isError($result))
{
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
elseif (!hasData($result))
{
$dms_id_arr = null;
}
else
{
$result = getData($result);
foreach($result as $doc) {
$dms_id_arr[] = array(
'name' => $doc->name,
'dms_id' => $doc->dms_id
);
}
}
foreach ($_FILES as $k => $file)
{
//update(2) alle neuen files (alle außer type application/x.fhc-dms+json) anhängen
if($file["type"] == 'application/x.fhc-dms+json')
{
$dms_uploaded[] = array(
'name' => $file["name"]
);
}
else
{
$dms = array(
'kategorie_kurzbz' => 'notiz',
'version' => 0,
'name' => $file["name"],
'mimetype' => $file["type"],
'insertamum' => date('c'),
'insertvon' => $uid
);
//Todo(manu) check if filetypes weiter eingeschränkt werden sollen
//Todo(manu)check name files: nicht gleiches file 2mal hochladen
$result = $this->dmslib->upload($dms, $k, array('*'));
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$dms_id = $result->retval['dms_id'];
$result = $this->NotizdokumentModel->insert(array('notiz_id' => $notiz_id, 'dms_id' => $dms_id));
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
}
}
//update(3) check if Dateien gelöscht wurden
if(count($dms_uploaded) != count($dms_id_arr))
{
if (count($dms_uploaded) == 0)
{
$filesDeleted = $dms_id_arr;
}
else
{
$upload_new_names = array_column($dms_uploaded, "name");
$filesDeleted = array_filter($dms_id_arr, function ($file) use ($upload_new_names) {
return !in_array($file["name"], $upload_new_names);
});
}
foreach ($filesDeleted as $file)
{
$result = $this->dmslib->removeAll($file['dms_id']);
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
else
$this->outputJson($result);
}
}
return $this->terminateWithSuccess($result);
}*/
/* public function deleteNotiz()
{
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
$notiz_id = $this->input->post('notiz_id');
$type = $this->input->post('type_id');
$id = $this->input->post('id');
//dms_id auslesen aus notizdokument wenn vorhanden
$dms_id_arr = [];
$this->load->model('person/Notizdokument_model', 'NotizdokumentModel');
$result = $this->NotizdokumentModel->loadWhere(array('notiz_id' => $notiz_id));
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
if(hasData($result))
{
$result = getData($result);
foreach ($result as $doc) {
$dms_id_arr[] = $doc->dms_id;
}
}
if($dms_id_arr)
{
$this->load->library('DmsLib');
foreach($dms_id_arr as $dms_id)
{
$result = $this->dmslib->removeAll($dms_id);
if (isError($result))
{
return $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
}
$this->outputJson($result);
}
}
//delete Notizzuordnung
if($type == "software_id")
{
// Loads extension Model
$this->load->model('extensions/FHC-Core-Softwarebereitstellung/Softwarenotizzuordnung_model', 'ExtensionnotizzuordnungModel');
$result = $this->ExtensionnotizzuordnungModel->delete([
'notiz_id' => $notiz_id,
'id' => strval($id)
],
[
'type_id' => $type
]);
}
else
{
//notizzuordnungsid!
$result = $this->NotizzuordnungModel->delete(['notiz_id' => $notiz_id, $type => $id]);
}
$this->load->model('person/Notiz_model', 'NotizModel');
//$this->NotizModel->addJoin('public.tbl_notizzuordnung', 'notiz_id');
//TODO (erweitern um Type_id) für Extensions, damit auch Notizzuordnung gelöscht werden kann
//Löschen von Notiz
$result = $this->NotizModel->delete(
array('notiz_id' => $notiz_id)
);
if (isError($result))
{
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
if(!hasData($result))
{
return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess(current(getData($result)));
}*/
/* public function loadDokumente()
{
$_POST = json_decode(utf8_encode($this->input->raw_input_stream), true);
$notiz_id = $this->input->post('notiz_id');
$this->NotizModel->addSelect('campus.tbl_dms_version.*');
$this->NotizModel->addJoin('public.tbl_notiz_dokument', 'ON (public.tbl_notiz_dokument.notiz_id = public.tbl_notiz.notiz_id)');
$this->NotizModel->addJoin('campus.tbl_dms_version', 'ON (public.tbl_notiz_dokument.dms_id = campus.tbl_dms_version.dms_id)');
$result = $this->NotizModel->loadWhere(
array('public.tbl_notiz.notiz_id' => $notiz_id)
);
if (isError($result)) {
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
if(!hasData($result))
{
return $this->terminateWithError($this->p->t('ui','error_missingId', ['id'=> 'Notiz_id']), self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess(getData($result));
}*/
/* public function getMitarbeiter($searchString)
{
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
$result = $this->MitarbeiterModel->searchMitarbeiter($searchString);
if (isError($result)) {
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
return $this->terminateWithSuccess($result);
}*/
public function isBerechtigt($id, $typeId)
{
if(!$this->permissionlib->isBerechtigt('admin', 'suid') && !$this->permissionlib->isBerechtigt('assistenz', 'suid'))
@@ -379,7 +63,6 @@ class Notiz extends Notiz_Controller
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
return success("berechtigt in überschreibender Funktion");
/* return $this->terminateWithError('keine Berechtigung bro', self::ERROR_TYPE_GENERAL);*/
}
}
}
@@ -90,15 +90,6 @@ class Projektarbeit extends FHCAPI_Controller
if (!isset($projektarbeit_id) || !is_numeric($projektarbeit_id)) return $this->terminateWithError('Projektarbeit Id missing', self::ERROR_TYPE_GENERAL);
$result = $this->fetchProjektarbeitByID($projektarbeit_id);
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess(current($data));
}
private function fetchProjektarbeitById($projektarbeit_id) {
$this->ProjektarbeitModel->resetQuery();
$this->ProjektarbeitModel->addSelect(
'lehre.tbl_projektarbeit.projektarbeit_id, titel, titel_english, themenbereich, projekttyp_kurzbz, lehrveranstaltung_id, lehreinheit_id,
firma_id, beginn, ende, gesperrtbis, note, final, freigegeben, tbl_projektarbeit.anmerkung, fa.name AS firma_name'
@@ -106,10 +97,13 @@ class Projektarbeit extends FHCAPI_Controller
$this->ProjektarbeitModel->addJoin('lehre.tbl_lehreinheit le', 'lehreinheit_id');
$this->ProjektarbeitModel->addJoin('lehre.tbl_lehrveranstaltung lv', 'lehrveranstaltung_id');
$this->ProjektarbeitModel->addJoin('public.tbl_firma fa', 'firma_id', 'LEFT');
return $this->ProjektarbeitModel->loadWhere(
$result = $this->ProjektarbeitModel->loadWhere(
array('projektarbeit_id' => $projektarbeit_id)
);
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess(current($data));
}
/**
@@ -138,8 +132,7 @@ class Projektarbeit extends FHCAPI_Controller
);
$data = $this->getDataOrTerminateWithError($result);
$data = $this->getDataOrTerminateWithError($this->fetchProjektarbeitById($data));
$this->terminateWithSuccess($data);
}
@@ -144,7 +144,6 @@ class Student extends FHCAPI_Controller
. $this->PrestudentModel->escape($studiensemester_kurzbz)
. ") AS statusofsemester"
);
$this->PrestudentModel->addSelect($this->PrestudentModel->escape($studiensemester_kurzbz) . ' as query_studiensemester_kurzbz');
$this->PrestudentModel->addJoin('public.tbl_student s', 'prestudent_id', 'LEFT');
$this->PrestudentModel->addJoin('public.tbl_benutzer b', 'student_uid = uid', 'LEFT');
@@ -147,7 +147,7 @@ class Students extends FHCAPI_Controller
$data = $this->getDataOrTerminateWithError($result);
$this->decodeTagsJsonInResult($data);
$this->terminateWithSuccess($data);
}
@@ -214,7 +214,7 @@ class Students extends FHCAPI_Controller
$data = $this->getDataOrTerminateWithError($result);
$this->decodeTagsJsonInResult($data);
$this->terminateWithSuccess($data);
}
@@ -267,7 +267,7 @@ class Students extends FHCAPI_Controller
$data = $this->getDataOrTerminateWithError($result);
$this->decodeTagsJsonInResult($data);
$this->terminateWithSuccess($data);
}
@@ -468,15 +468,13 @@ class Students extends FHCAPI_Controller
$this->PrestudentModel->addSelect("'' AS verband");
$this->PrestudentModel->addSelect("'' AS gruppe");
$this->addSelectPrioRel();
$query_studiensemester_kurzbz = $studiensemester_kurzbz ? $this->PrestudentModel->escape($studiensemester_kurzbz) : '\'NULL\'';
$this->PrestudentModel->addSelect($query_studiensemester_kurzbz . ' as query_studiensemester_kurzbz');
$this->addFilter($studiensemester_kurzbz);
$result = $this->PrestudentModel->loadWhere($where);
$data = $this->getDataOrTerminateWithError($result);
$this->decodeTagsJsonInResult($data);
$this->terminateWithSuccess($data);
}
@@ -590,7 +588,6 @@ class Students extends FHCAPI_Controller
$this->PrestudentModel->addSelect('v.verband');
$this->PrestudentModel->addSelect('v.gruppe');
$this->PrestudentModel->addSelect("'' AS priorisierung_relativ");
$this->PrestudentModel->addSelect($this->PrestudentModel->escape($studiensemester_kurzbz) . ' as query_studiensemester_kurzbz');
$where = [];
@@ -631,20 +628,8 @@ class Students extends FHCAPI_Controller
$result = $this->PrestudentModel->loadWhere($where);
$data = $this->getDataOrTerminateWithError($result);
$this->decodeTagsJsonInResult($data);
$this->terminateWithSuccess($data);
}
protected function decodeTagsJsonInResult(&$data)
{
if(defined('STV_TAGS_ENABLED') && STV_TAGS_ENABLED) {
array_walk($data, function($item, $key) {
if(isset($item->tags))
{
$item->tags = json_decode($item->tags);
}
});
}
$this->terminateWithSuccess($data);
}
/**
@@ -691,7 +676,7 @@ class Students extends FHCAPI_Controller
]);
$data = $this->getDataOrTerminateWithError($result);
$this->decodeTagsJsonInResult($data);
$this->terminateWithSuccess($data);
}
@@ -734,7 +719,7 @@ class Students extends FHCAPI_Controller
]);
$data = $this->getDataOrTerminateWithError($result);
$this->decodeTagsJsonInResult($data);
$this->terminateWithSuccess($data);
}
@@ -776,7 +761,7 @@ class Students extends FHCAPI_Controller
]);
$data = $this->getDataOrTerminateWithError($result);
$this->decodeTagsJsonInResult($data);
$this->terminateWithSuccess($data);
}
@@ -813,7 +798,6 @@ class Students extends FHCAPI_Controller
$this->PrestudentModel->addSelect("COALESCE(v.semester::text, CASE WHEN public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL) IN ('Aufgenommener', 'Bewerber', 'Wartender', 'interessent') THEN public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)::text ELSE ''::text END) AS semester", false);
$this->PrestudentModel->addSelect('v.verband');
$this->PrestudentModel->addSelect('v.gruppe');
$this->PrestudentModel->addSelect($this->PrestudentModel->escape($studiensemester_kurzbz) . ' as query_studiensemester_kurzbz');
//add status per semester
$this->PrestudentModel->addSelect(
@@ -852,7 +836,7 @@ class Students extends FHCAPI_Controller
$result = $this->PrestudentModel->load();
$data = $this->getDataOrTerminateWithError($result);
$this->decodeTagsJsonInResult($data);
$this->terminateWithSuccess($data);
}
@@ -894,31 +878,12 @@ class Students extends FHCAPI_Controller
n.text AS notiz,
nt.style,
n.erledigt AS done,
nz.prestudent_id,
n.start,
n.ende
nz.prestudent_id
FROM public.tbl_notizzuordnung AS nz
JOIN public.tbl_notiz AS n ON nz.notiz_id = n.notiz_id AND nz.prestudent_id IS NOT NULL
JOIN public.tbl_notiz AS n ON nz.notiz_id = n.notiz_id
JOIN public.tbl_notiz_typ AS nt ON n.typ = nt.typ_kurzbz "
. $whereTags .
"
WHERE
COALESCE(n.start, '1970-01-01') <= (
SELECT
ende
FROM
public.tbl_studiensemester
WHERE
studiensemester_kurzbz = '{$studiensemester_kurzbz}'
)
AND COALESCE(n.ende, '2170-12-31') >= (
SELECT
start
FROM
public.tbl_studiensemester
WHERE
studiensemester_kurzbz = '{$studiensemester_kurzbz}'
)
) AS tag
GROUP BY tag.prestudent_id
) AS tag_data_agg
@@ -988,13 +953,6 @@ class Students extends FHCAPI_Controller
$this->PrestudentModel->addSelect('pls.status_kurzbz AS status');
$this->PrestudentModel->addSelect('pls.datum AS status_datum');
$this->PrestudentModel->addSelect('pls.bestaetigtam AS status_bestaetigung');
$this->PrestudentModel->addSelect("
CASE
WHEN pls.status_kurzbz = 'Interessent'
THEN pls.ausbildungssemester
ELSE s.semester
END AS semester_berechnet
");
$this->PrestudentModel->addSelect(
"(SELECT kontakt FROM public.tbl_kontakt WHERE kontakttyp='email' AND person_id=p.person_id AND zustellung LIMIT 1) AS mail_privat",
false
@@ -45,5 +45,4 @@ class Tags extends Tag_Controller
{
parent::doneTag($this->config->item('stv_prestudent_tags'));
}
}
+13 -42
View File
@@ -13,13 +13,12 @@ class Mylv extends Auth_Controller
*/
public function __construct()
{
parent::__construct([
'Student' => ['student/anrechnung_beantragen:r','user:r', 'basis/cis:r'], // TODO(chris): permissions?
'Studiensemester' => ['student/anrechnung_beantragen:r','user:r', 'basis/cis:r'], // TODO(chris): permissions?
'Lvs' => ['student/anrechnung_beantragen:r','user:r', 'basis/cis:r'], // TODO(chris): permissions?
'Info' => ['student/anrechnung_beantragen:r','user:r', 'basis/cis:r'], // TODO(chris): permissions?
'Pruefungen' => ['student/anrechnung_beantragen:r','user:r', 'basis/cis:r'] // TODO(chris): permissions?
'Student' => ['student/anrechnung_beantragen:r','user:r'], // TODO(chris): permissions?
'Studiensemester' => ['student/anrechnung_beantragen:r','user:r'], // TODO(chris): permissions?
'Lvs' => ['student/anrechnung_beantragen:r','user:r'], // TODO(chris): permissions?
'Info' => ['student/anrechnung_beantragen:r','user:r'], // TODO(chris): permissions?
'Pruefungen' => ['student/anrechnung_beantragen:r','user:r'] // TODO(chris): permissions?
]);
}
@@ -45,27 +44,13 @@ class Mylv extends Auth_Controller
public function Studiensemester()
{
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$this->load->model('crm/Student_model', 'StudentModel');
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
$isMitarbeiter = getData($this->MitarbeiterModel->isMitarbeiter(getAuthUID())) ?? false;
if($isMitarbeiter) {
$result = $this->StudiensemesterModel->getWhereMitarbeiterHasLvs(getAuthUID());
$result = $this->StudiensemesterModel->getWhereStudentHasLvs(getAuthUID());
if (isError($result))
return $this->outputJsonError(getError($result));
if (isError($result))
return $this->outputJsonError(getError($result));
$this->outputJsonSuccess(getData($result));
} else if(getData($this->StudentModel->isStudent(getAuthUID())) ?? false) { // $isStudent
$result = $this->StudiensemesterModel->getWhereStudentHasLvs(getAuthUID());
if (isError($result))
return $this->outputJsonError(getError($result));
$this->outputJsonSuccess(getData($result));
} else {
$this->outputJsonError('neither student or mitarbeiter');
}
$this->outputJsonSuccess(getData($result));
}
/**
@@ -73,27 +58,13 @@ class Mylv extends Auth_Controller
public function Lvs($studiensemester_kurzbz)
{
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
$this->load->model('crm/Student_model', 'StudentModel');
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
$isMitarbeiter = getData($this->MitarbeiterModel->isMitarbeiter(getAuthUID())) ?? false;
if($isMitarbeiter) {
$result = $this->LehrveranstaltungModel->getLvsByMitarbeiterInSemester(getAuthUID(), $studiensemester_kurzbz);
$result = $this->LehrveranstaltungModel->getLvsByStudentWithGrades(getAuthUID(), $studiensemester_kurzbz, getUserLanguage());
if (isError($result))
return $this->outputJsonError(getError($result));
if (isError($result))
return $this->outputJsonError(getError($result));
$this->outputJsonSuccess(getData($result));
} else if(getData($this->StudentModel->isStudent(getAuthUID())) ?? false) { // $isStudent
$result = $this->LehrveranstaltungModel->getLvsByStudentWithGrades(getAuthUID(), $studiensemester_kurzbz, getUserLanguage());
if (isError($result))
return $this->outputJsonError(getError($result));
$this->outputJsonSuccess(getData($result));
} else {
$this->outputJsonError('neither student or mitarbeiter');
}
$this->outputJsonSuccess(getData($result));
}
/**
-117
View File
@@ -1,117 +0,0 @@
<?php
if (!defined("BASEPATH")) exit("No direct script access allowed");
use \DateTime as DateTime;
class TagJob extends JOB_Controller
{
const BATCHUSER = 'sftest';
/**
* API constructor
*/
public function __construct()
{
parent::__construct();
// Configs
$this->load->config('stv');
// Library
$this->load->library('TagLib');
// Load Models
$this->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$this->load->model('system/Notiztyp_model', 'NotiztypModel');
$this->loadPhrases([
'lehre'
]);
}
public function rebuildAutomatedTags()
{
$automatedTagsRes = $this->NotiztypModel->loadWhere(array('automatisiert' => true, 'taglib IS NOT NULL' => null));
$automatedTags = hasData($automatedTagsRes) ? getData($automatedTagsRes) : [];
$result = $this->StudiensemesterModel->getAktOrNextSemester();
if (isError($result))
{
$this->logInfo('Start Job rebuild Automated Tags');
$this->logError('Error occurred during retrieving studiensemester');
return $this->logInfo('End Job rebuild Automated Tags');
}
if (empty($result->retval) || !isset($result->retval[0])) {
$this->logInfo('Start Job rebuild Automated Tags');
$this->logError('No Studiensemester found');
return $this->logInfo('End Job rebuild Automated Tags');
}
$studiensemester_kurzbz = $result->retval[0]->studiensemester_kurzbz ?? null;
$params = array(
'studiensemester_kurzbz' => $studiensemester_kurzbz
);
$this->logInfo('Start Job rebuild Automated Tags ' . $studiensemester_kurzbz);
foreach($automatedTags as $autoTag)
{
// getPath: must not be lost
$filePath = APPPATH . 'libraries/' . $autoTag->taglib . '.php'; // APPPATH = application/
if(file_exists($filePath)) {
require_once($filePath);
} else {
$this->logInfo("File not found: " . $filePath);
continue;
}
$kurz_bz = $autoTag->typ_kurzbz;
// className without PATH (basename)
$className = basename($autoTag->taglib);
$obj = new $className();
$outputArray = $obj->getZuordnungIds($params);
$typeId = $outputArray->typeId;
$paramsTag = array(
'studiensemester_kurzbz' => $studiensemester_kurzbz,
'kurzbz' => $kurz_bz,
'data' => $outputArray->data,
'typeId' => $typeId
);
$result = $this->taglib->updateAutomatedTags($paramsTag);
if (isError($result)) {
$this->logError('Error occurred during updateAutomatedTags ' . $kurz_bz);
continue;
}
$data = is_array($result) ? $result['retval'] : $result->retval;
//SUMMARY
$this->logInfo("Tag " . $result->retval['input']['tag'] . " | type_id " . $typeId . " --"
. " Count Recycled: " . $result->retval['summary']['recycled']
. " Count Added: ". $result->retval['summary']['added']
. " Count Deleted: ". $result->retval['summary']['deleted']);
//DETAILS
if($result->retval['results']['newTags'])
$this->logInfo("Tag " . $result->retval['input']['tag'] . "New tag(s): " . implode(', ', $result->retval['results']['newTags']));
if($result->retval['results']['deletedTagsIds'])
$this->logInfo("Tag " . $result->retval['input']['tag'] . "Deleted tags(s: " . implode(', ', $result->retval['results']['deletedTagsIds']));
if ($result->retval['results']['retaggedIds'])
$this->logInfo("Tag " . $result->retval['input']['tag'] . "Recycled tag(s): " . implode(', ', $result->retval['results']['retaggedIds']));
}
$this->logInfo( "End Job rebuild Automated Tags");
}
}
@@ -73,7 +73,7 @@ class Attachment extends FHC_Controller
}
}
$result = $this->dmslib->download($dms_id);
$result = $this->dmslib->getOutputFileInfo($dms_id);
if (isError($result))
return show_error(getError($result));
@@ -215,11 +215,8 @@ class Pruefungsprotokoll extends Auth_Controller
if (hasData($abschlusspruefung))
{
$abschlusspruefung_data = getData($abschlusspruefung);
if ($this->permissionlib->isBerechtigt('admin')
|| (
isset($abschlusspruefung_data->studiengang_kz)
&& $this->permissionlib->isBerechtigt('assistenz', 'suid', $abschlusspruefung_data->studiengang_kz)
)
if ($this->permissionlib->isBerechtigt('admin') ||
(isset($abschlusspruefung_data->studiengang_kz) && $this->permissionlib->isBerechtigt('assistenz', 'suid', $abschlusspruefung_data->studiengang_kz))
|| $this->_uid === $abschlusspruefung_data->uid_vorsitz)
$result = $abschlusspruefung;
else
@@ -393,7 +393,7 @@ class approveAnrechnungDetail extends Auth_Controller
$filename = $this->anrechnunglib->setFilenameOnDownload($dms_id);
// Get file to be downloaded from DMS
$download = $this->dmslib->download($dms_id, $filename);
$download = $this->dmslib->getOutputFileInfo($dms_id, $filename);
if (isError($download)) return $download;
// Download file
@@ -282,7 +282,7 @@ class approveAnrechnungUebersicht extends Auth_Controller
$filename = $this->anrechnunglib->setFilenameOnDownload($dms_id);
// Get file to be downloaded from DMS
$download = $this->dmslib->download($dms_id, $filename);
$download = $this->dmslib->getOutputFileInfo($dms_id, $filename);
if (isError($download)) return $download;
// Download file
@@ -150,15 +150,12 @@ class CreateAnrechnung extends Auth_Controller
}
// Upload document
$result = self::_uploadFile();
$result = $this->_uploadFile();
if (isError($result))
{
$this->terminateWithJsonError($result->retval);
}
if (isError($result)) $this->terminateWithJsonError(getError($result));
// Hold just inserted DMS ID
$lastInsert_dms_id = $result->retval['dms_id'];
$lastInsert_dms_id = getData($result)->dms_id;
// Save Anrechnung and Anrechnungstatus
$result = $this->AnrechnungModel->createAnrechnungsantrag(
@@ -227,17 +224,25 @@ class CreateAnrechnung extends Auth_Controller
*/
private function _uploadFile()
{
$dms = array(
'kategorie_kurzbz' => 'anrechnung',
'version' => 0,
'name' => $_FILES['uploadfile']['name'],
'mimetype' => $_FILES['uploadfile']['type'],
'insertamum' => (new DateTime())->format('Y-m-d H:i:s'),
'insertvon' => $this->_uid
);
// Upload document
return $this->dmslib->upload($dms, 'uploadfile', array('pdf'));
$uploadDataResult = $this->uploadFile('uploadfile', array('pdf'));
// If an error occurred while uploading the file
if (isError($uploadDataResult)) return $uploadDataResult;
if (!hasData($uploadDataResult)) return error('Upload failed');
// Add file to the DMS (DB + file system)
return $this->_ci->dmslib->add(
getData($uploadDataResult)['file_name'],
getData($uploadDataResult)['file_type'],
fopen(getData($uploadDataResult)['full_path'], 'r'),
'anrechnung', // kategorie_kurzbz
null, // dokument_kurzbz
null, // beschreibung
false, // cis_suche
null, // schlagworte
getAuthUID() // insertvon
);
}
private function _LVhasBlockingGrades($studiensemester_kurzbz, $lehrveranstaltung_id, $prestudent_id)
@@ -268,4 +273,4 @@ class CreateAnrechnung extends Auth_Controller
return false;
}
}
}
@@ -83,7 +83,7 @@ class requestAnrechnung extends Auth_Controller
$is_expired = $this->_isExpired($studiensemester_kurzbz);
// Check if Lehrveranstaltung was already graded with application blocking grades
$is_blocked = self::_LVhasBlockingGrades($studiensemester_kurzbz, $lehrveranstaltung_id);
$is_blocked = $this->_LVhasBlockingGrades($studiensemester_kurzbz, $lehrveranstaltung_id);
// Get Anrechung data
$anrechnungData = $this->anrechnunglib->getAnrechnungDataByLv($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id);
@@ -152,27 +152,24 @@ class requestAnrechnung extends Auth_Controller
$prestudent_id = getData($result)[0]->prestudent_id;
// Exit if application already exists
if (self::_applicationExists($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id))
if ($this->_applicationExists($lehrveranstaltung_id, $studiensemester_kurzbz, $prestudent_id))
{
return $this->outputJsonError($this->p->t('anrechnung', 'antragBereitsGestellt'));
}
// Exit if application is a past ( < actual ) studysemester
if (self::_applicationIsPastSS($studiensemester_kurzbz))
if ($this->_applicationIsPastSS($studiensemester_kurzbz))
{
return $this->outputJsonError($this->p->t('anrechnung', 'antragNichtFuerVerganganeSS'));
}
// Upload document
$result = self::_uploadFile();
$result = $this->_uploadFile();
if (isError($result))
{
return $this->outputJsonError($result->retval);
}
if (isError($result)) return $this->outputJsonError(getError($result));
// Hold just inserted DMS ID
$lastInsert_dms_id = $result->retval['dms_id'];
$lastInsert_dms_id = getData($result)->dms_id;
// Save Anrechnung and Anrechnungstatus
$result = $this->AnrechnungModel->createAnrechnungsantrag(
@@ -182,8 +179,8 @@ class requestAnrechnung extends Auth_Controller
$begruendung_id,
$lastInsert_dms_id,
$anmerkung,
$begruendung_ects,
$begruendung_lvinhalt
$begruendung_ects,
$begruendung_lvinhalt
);
if (isError($result))
@@ -215,11 +212,11 @@ class requestAnrechnung extends Auth_Controller
$this->_checkIfEntitledToReadDMSDoc($dms_id);
// Get file to be downloaded from DMS
$download = $this->dmslib->download($dms_id);
if (isError($download)) return $download;
$download = $this->dmslib->getOutputFileInfo($dms_id);
if (isError($download)) return $download;
// Download file
$this->outputFile(getData($download));
// Download file
$this->outputFile(getData($download));
}
/**
@@ -367,16 +364,25 @@ class requestAnrechnung extends Auth_Controller
*/
private function _uploadFile()
{
$dms = array(
'kategorie_kurzbz' => 'anrechnung',
'version' => 0,
'name' => $_FILES['uploadfile']['name'],
'mimetype' => $_FILES['uploadfile']['type'],
'insertamum' => (new DateTime())->format('Y-m-d H:i:s'),
'insertvon' => $this->_uid
);
// Upload document
return $this->dmslib->upload($dms, 'uploadfile', array('pdf'));
$uploadDataResult = $this->uploadFile('uploadfile', array('pdf'));
// If an error occurred while uploading the file
if (isError($uploadDataResult)) return $uploadDataResult;
// If an error occurred while uploading the file
if (!hasData($uploadDataResult)) return error('Upload failed');
// Add file to the DMS (DB + file system)
return $this->_ci->dmslib->add(
getData($uploadDataResult)['file_name'],
getData($uploadDataResult)['file_type'],
fopen(getData($uploadDataResult)['full_path'], 'r'),
'anrechnung',
null, // dokument_kurzbz
null, // beschreibung
false, // cis_suche
null, // schlagworte
getAuthUID() // insertvon
);
}
}
@@ -237,7 +237,7 @@ class reviewAnrechnungDetail extends Auth_Controller
$filename = $this->anrechnunglib->setFilenameOnDownload($dms_id);
// Get file to be downloaded from DMS
$download = $this->dmslib->download($dms_id, $filename);
$download = $this->dmslib->getOutputFileInfo($dms_id, $filename);
if (isError($download)) return $download;
// Download file
@@ -196,7 +196,7 @@ class reviewAnrechnungUebersicht extends Auth_Controller
$filename = $this->anrechnunglib->setFilenameOnDownload($dms_id);
// Get file to be downloaded from DMS
$download = $this->dmslib->download($dms_id, $filename);
$download = $this->dmslib->getOutputFileInfo($dms_id, $filename);
if (isError($download)) return $download;
// Download file
+3 -15
View File
@@ -198,19 +198,7 @@ class Gradelist extends Auth_Controller
if (!isset($row_noten->found))
{
$result_lv = $this->LehrveranstaltungModel->load($row_noten->lehrveranstaltung_id);
$studiengang_kz = null;
if (!empty($result_lv->retval) && isset($result_lv->retval[0]) && isset($result_lv->retval[0]->studiengang_kz))
{
$result_stg = $this->StudiengangModel->load($result_lv->retval[0]->studiengang_kz);
if (!empty($result_stg->retval) && isset($result_stg->retval[0]) && is_object($result_stg->retval[0]) && isset($result_stg->retval[0]->kurzbzlang))
{
$studiengang_kz = $result_stg->retval[0]->kurzbzlang;
}
}
$result_stg = $this->StudiengangModel->load($result_lv->retval[0]->studiengang_kz);
$courses['semester'][$row_noten->studiensemester_kurzbz]['lvs_nonstpl'][] = array(
'lehrveranstaltung_id' => $row_noten->lehrveranstaltung_id,
'lehrtyp_kurzbz' => $result_lv->retval[0]->lehrtyp_kurzbz,
@@ -224,8 +212,8 @@ class Gradelist extends Auth_Controller
'semester' => $result_lv->retval[0]->semester,
'note' => $row_noten->note,
'datum' => $row_noten->benotungsdatum,
'studiengang_kurzbz' => $studiengang_kz,
'zugeordnet' => true
'zugeordnet' => true,
'studiengang_kurzbz' => $result_stg->retval[0]->kurzbzlang
);
if(!isset($courses['semester'][$row_noten->studiensemester_kurzbz]['data']['ectssumme_nonstpl']))
$courses['semester'][$row_noten->studiensemester_kurzbz]['data']['ectssumme_nonstpl'] = 0;
@@ -179,6 +179,7 @@ class InfoCenter extends Auth_Controller
// Loads libraries
$this->load->library('PersonLogLib');
$this->load->library('WidgetLib');
$this->load->library('AkteLib');
$this->load->config('infocenter');
@@ -452,8 +453,7 @@ class InfoCenter extends Auth_Controller
if (isset($akte_id) && isset($person_id))
{
$this->load->library('AkteLib');
$akte = $this->aktelib->get($akte_id);
$akte = $this->aktelib->getByAkteId($akte_id);
if (hasData($akte))
{
@@ -1169,8 +1169,6 @@ class InfoCenter extends Auth_Controller
*/
public function outputAkteContent($akte_id)
{
$this->load->library('DmsLib');
$akte = $this->AkteModel->load($akte_id);
if (isError($akte))
@@ -1178,7 +1176,7 @@ class InfoCenter extends Auth_Controller
show_error(getError($akte));
}
$aktecontent = $this->dmslib->getAkteContent($akte_id);
$aktecontent = $this->aktelib->getByAkteId($akte_id);
if (isError($aktecontent))
{
@@ -2468,4 +2466,4 @@ class InfoCenter extends Auth_Controller
$this->outputJsonSuccess("Success");
}
}
}
+121 -19
View File
@@ -136,37 +136,77 @@ abstract class FHC_Controller extends CI_Controller
/**
* To download the given file represented by the fileObj parameter.
* fileObj has the following structure:
* $fileObj->filename
* $fileObj->file
* $fileObj->file OR $fileObj->file_content
* $fileObj->name
* $fileObj->mimetype
* $fileObj->disposition
* $fileObj->disposition (inline OR attachment)
*/
protected function outputFile($fileObj)
{
// If the file exists
if (isset($fileObj->file) && !isEmptyString($fileObj->file) && file_exists($fileObj->file))
if ((isset($fileObj->file) && !isEmptyString($fileObj->file) && file_exists($fileObj->file))
|| (isset($fileObj->file_content) && !isEmptyString($fileObj->file_content)))
{
header('Content-Description: File Transfer');
header('Content-Type: '. $fileObj->mimetype);
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($fileObj->file));
$content_length = 0;
if (isset($fileObj->disposition)
&& ($fileObj->disposition == 'inline' || $fileObj->disposition == 'attachment'))
// If file content has been provided
if (isset($fileObj->file_content) && !isEmptyString($fileObj->file_content))
{
header('Content-Disposition: '. $fileObj->disposition. '; filename="'. $fileObj->name. '"');
$content_length = strlen($fileObj->file_content);
}
else // otherwise the path + name of the file
{
$content_length = filesize($fileObj->file);
}
readfile($fileObj->file); // reads the file content to the output buffer
}
else
{
// Otherwise print an error
show_error('The provided file does not exist: '.(isset($fileObj->file) ? $fileObj->file : 'file not given'));
header('Content-Description: File Transfer');
header('Content-Type: '. $fileObj->mimetype);
header('Content-Length: ' . $content_length);
header('Content-Transfer-Encoding: binary');
header('Content-Disposition: '. $fileObj->disposition. '; filename="'. $fileObj->name. '"');
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Expires: ' . date("D, d M Y H:i:s", time()));
header('Pragma: public');
// Clean the output buffer
flush();
// If file content has been provided
if (isset($fileObj->file_content) && !isEmptyString($fileObj->file_content))
{
echo $fileObj->file_content;
}
else // otherwise get the content from file system
{
readfile($fileObj->file);
}
// Terminate the execution
exit();
}
// Otherwise return an error
show_error('The provided file does not exist or file content is empty');
}
/**
*
*/
protected function outputImageByContent($mimetype, $file_content)
{
if (isEmptyString($file_content)) show_error('The provided file content is not valid');
$this->_outputImage($mimetype, $file_content);
}
/**
*
*/
protected function outputImageByFile($mimetype, $file_name)
{
if (!file_exists($file_name)) show_error('The provided file does not exist');
$this->_outputImage($mimetype, null, $file_name);
}
/**
@@ -178,6 +218,29 @@ abstract class FHC_Controller extends CI_Controller
return json_decode($this->input->raw_input_stream);
}
/**
* Utility function to upload a file
* - post_field_name: the name of the field in the HTTP POST payload, this is also the index in the super global $_FILES array
* - allowed_types: a list of file extensions that are allowed to be uploaded (ex. array('pdf', 'odt') or array('jpg', 'jpeg', 'gif')
*/
protected function uploadFile($post_field_name, $allowed_types = array('*'))
{
$this->load->library(
'upload',
array(
'upload_path' => sys_get_temp_dir(),
'allowed_types' => $allowed_types,
'overwrite' => true
)
);
// If the upload was a success then return the uploaded file info
if ($this->upload->do_upload($post_field_name)) return success($this->upload->data());
// If an error occurred then return it without tags
return error($this->upload->display_errors('', ''));
}
//------------------------------------------------------------------------------------------------------------------
// Private methods
@@ -193,5 +256,44 @@ abstract class FHC_Controller extends CI_Controller
show_error('This web site cannot work correctly without the HTTPS protocol enabled');
}
}
/**
*
*/
private function _outputImage($mimetype, $file_content = null, $file_name = null)
{
$content_length = 0;
// If file content has been provided
if ($file_content != null)
{
$content_length = strlen($file_content);
}
else // otherwise the path + name of the file
{
$content_length = filesize($file_name);
}
header('Content-Type: '. $mimetype);
header('Content-Length: ' . $content_length);
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Expires: ' . date("D, d M Y H:i:s", time()));
// Clean the output buffer
flush();
// If file content has been provided
if ($file_content != null)
{
echo $file_content;
}
else // otherwise get the content from file system
{
readfile($file_name);
}
// Terminate the execution
exit();
}
}
+57 -27
View File
@@ -196,26 +196,39 @@ abstract class Notiz_Controller extends FHCAPI_Controller
$dms_id_arr = [];
foreach ($_FILES as $k => $file)
{
$dms = array(
'kategorie_kurzbz' => 'notiz',
'version' => 0,
'name' => $file["name"],
'mimetype' => $file["type"],
'insertamum' => date('c'),
'insertvon' => $uid
);
//Todo(manu) check if filetypes weiter eingeschränkt werden sollen
//Todo(manu)check name files: nicht gleiches file 2mal hochladen
//Todo define in dms component: readFile, downloadFile
$result = $this->dmslib->upload($dms, $k, ['*']);
/* $result = $this->dmslib->upload($dms, $k, ['application/pdf','application/x.fhc-dms+json']);*/
if (isError($result))
$uploadDataResult = $this->uploadFile($k);
if (isError($uploadDataResult))
{
$this->db->trans_rollback();
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
$this->terminateWithError(getError($uploadDataResult), self::ERROR_TYPE_GENERAL);
}
$dms_id_arr[] = $result->retval['dms_id'];
if (!hasData($uploadDataResult))
{
$this->db->trans_rollback();
$this->terminateWithError('Upload failed', self::ERROR_TYPE_GENERAL);
}
// Add file to the DMS (DB + file system)
$addResult = $this->dmslib->add(
getData($uploadDataResult)['file_name'],
getData($uploadDataResult)['file_type'],
fopen(getData($uploadDataResult)['full_path'], 'r'),
'notiz', // kategorie_kurzbz
null, // dokument_kurzbz
null, // beschreibung
false, // cis_suche
null, // schlagworte
getAuthUID() // insertvon
);
// If error occurred
if (isError($addResult) || !hasData($addResult))
$this->terminateWithError(getError($addResult), self::ERROR_TYPE_GENERAL);
$dms_id_arr[] = getData($addResult)->dms_id;
}
//save entry in Notizdokument
@@ -319,22 +332,40 @@ abstract class Notiz_Controller extends FHCAPI_Controller
}
else
{
$dms = array(
'kategorie_kurzbz' => 'notiz',
'version' => 0,
'name' => $file["name"],
'mimetype' => $file["type"],
'insertamum' => date('c'),
'insertvon' => $uid
);
//Todo(manu) check if filetypes weiter eingeschränkt werden sollen
//Todo(manu)check name files: nicht gleiches file 2mal hochladen
//Todo define in dms component: readFile, downloadFile
$result = $this->dmslib->upload($dms, $k, array('*'));
$uploadDataResult = $this->uploadFile($k);
if (isError($uploadDataResult))
{
$this->db->trans_rollback();
$this->terminateWithError(getError($uploadDataResult), self::ERROR_TYPE_GENERAL);
}
if (!hasData($uploadDataResult))
{
$this->db->trans_rollback();
$this->terminateWithError('Upload failed', self::ERROR_TYPE_GENERAL);
}
$result = $this->getDataOrTerminateWithError($result);
$dms_id = $result['dms_id'];
// Add file to the DMS (DB + file system)
$addResult = $this->dmslib->add(
getData($uploadDataResult)['file_name'],
getData($uploadDataResult)['file_type'],
fopen(getData($uploadDataResult)['full_path'], 'r'),
'notiz', // kategorie_kurzbz
null, // dokument_kurzbz
null, // beschreibung
false, // cis_suche
null, // schlagworte
getAuthUID() // insertvon
);
// If error occurred
if (isError($addResult) || !hasData($addResult))
$this->terminateWithError(getError($addResult), self::ERROR_TYPE_GENERAL);
$addResult = $this->getDataOrTerminateWithError($addResult);
$dms_id = $addResult['dms_id'];
$result = $this->NotizdokumentModel->insert(array('notiz_id' => $post_data['notiz_id'], 'dms_id' => $dms_id));
@@ -417,7 +448,6 @@ abstract class Notiz_Controller extends FHCAPI_Controller
$notiz_id = $this->input->post('notiz_id');
$this->NotizModel->addSelect('campus.tbl_dms_version.*');
$this->NotizModel->addSelect($this->NotizModel->escape(base_url('content/notizdokdownload.php?id=')) . ' || public.tbl_notiz_dokument.dms_id AS preview');
$this->NotizModel->addJoin('public.tbl_notiz_dokument', 'ON (public.tbl_notiz_dokument.notiz_id = public.tbl_notiz.notiz_id)');
$this->NotizModel->addJoin('campus.tbl_dms_version', 'ON (public.tbl_notiz_dokument.dms_id = campus.tbl_dms_version.dms_id)');
+7 -86
View File
@@ -15,11 +15,10 @@ class Tag_Controller extends FHCAPI_Controller
'getTag' => self::BERECHTIGUNG_KURZBZ,
'getTags' => self::BERECHTIGUNG_KURZBZ,
'addTag' => self::BERECHTIGUNG_KURZBZ,
'updateTag' => self::BERECHTIGUNG_KURZBZ,
'doneTag' => self::BERECHTIGUNG_KURZBZ,
'deleteTag' => self::BERECHTIGUNG_KURZBZ,
'getAllTags' => self::BERECHTIGUNG_KURZBZ,
'rebuildTagsForTypeId' => self::BERECHTIGUNG_KURZBZ,
];
$merged_permissions = array_merge($default_permissions, $permissions);
@@ -27,10 +26,6 @@ class Tag_Controller extends FHCAPI_Controller
parent::__construct($merged_permissions);
$this->_setAuthUID();
// Library
$this->load->library('TagLib');
$this->load->model('person/Notiz_model', 'NotizModel');
$this->load->model('system/Notiztyp_model', 'NotiztypModel');
$this->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
@@ -42,6 +37,7 @@ class Tag_Controller extends FHCAPI_Controller
public function getTag($readonly_tags = null)
{
$language = $this->_getLanguageIndex();
$id = $this->input->get('id');
if (is_array($readonly_tags) && !isEmptyArray($readonly_tags))
@@ -66,17 +62,14 @@ class Tag_Controller extends FHCAPI_Controller
$this->NotizModel->addSelect(
"tbl_notiz.titel,
tbl_notiz.text,
array_to_json(bezeichnung_mehrsprachig::varchar[])->>0 as bezeichnung,
array_to_json(bezeichnung_mehrsprachig::varchar[])->>". $language. " as bezeichnung,
tbl_notiz.notiz_id,
tbl_notiz_typ.style,
tbl_notiz_typ.automatisiert,
tbl_notiz.erledigt as done,
tbl_notiz.insertamum,
tbl_notiz.updateamum,
(verfasserperson.vorname || ' ' || verfasserperson.nachname || ' ' || '(' || verfasserbenutzer.uid || ')') as verfasser,
(bearbeiterperson.vorname || ' ' || bearbeiterperson.nachname || ' ' || '(' || bearbeiterbenutzer.uid || ')') as bearbeiter,
tbl_notiz.start,
tbl_notiz.ende
(bearbeiterperson.vorname || ' ' || bearbeiterperson.nachname || ' ' || '(' || bearbeiterbenutzer.uid || ')') as bearbeiter
"
);
$this->NotizModel->addJoin('public.tbl_notiz_typ', 'public.tbl_notiz.typ = public.tbl_notiz_typ.typ_kurzbz');
@@ -89,22 +82,18 @@ class Tag_Controller extends FHCAPI_Controller
$notiz = $this->NotizModel->loadWhere(array('notiz_id' => $id));
$this->terminateWithSuccess(hasData($notiz) ? getData($notiz)[0] : array());
}
public function getTags($tags = null)
{
$language = $this->_getLanguageIndex();
$this->NotiztypModel->addSelect(
"typ_kurzbz as tag_typ_kurzbz,
'typ_kurzbz as tag_typ_kurzbz,
array_to_json(bezeichnung_mehrsprachig::varchar[])->>0 as bezeichnung,
style,
beschreibung,
tag,
automatisiert
"
tag
'
);
$this->NotiztypModel->addOrder('prioritaet');
@@ -282,74 +271,6 @@ class Tag_Controller extends FHCAPI_Controller
$this->terminateWithSuccess($deleteNotiz);
}
public function getAllTags($readonly_tags = false){
$prestudent_id = $this->input->get('prestudent_id');
//TODO check for readonly: necessary?
if (is_array($readonly_tags) && !isEmptyArray($readonly_tags))
{
$readonly_tags = $this->_filterTag($readonly_tags, true);
foreach ($readonly_tags as $key => $tag)
{
$readonly_tags[$key] = $this->NotizModel->db->escape($tag);
}
$tags = '(' . implode(',', $readonly_tags) . ')';
$this->NotizModel->addSelect("
CASE
WHEN tbl_notiz_typ.typ_kurzbz IN $tags
THEN TRUE
ELSE FALSE
END as readonly
");
}
$this->NotizModel->addSelect(
"tbl_notiz.titel,
tbl_notiz.text,
array_to_json(bezeichnung_mehrsprachig::varchar[])->>0 as bezeichnung,
tbl_notiz.notiz_id,
tbl_notiz_typ.style,
tbl_notiz_typ.automatisiert,
tbl_notiz.erledigt as done,
tbl_notiz.insertamum,
tbl_notiz.updateamum,
(verfasserperson.vorname || ' ' || verfasserperson.nachname || ' ' || '(' || verfasserbenutzer.uid || ')') as verfasser,
(bearbeiterperson.vorname || ' ' || bearbeiterperson.nachname || ' ' || '(' || bearbeiterbenutzer.uid || ')') as bearbeiter,
tbl_notiz.start,
tbl_notiz.ende
"
);
$this->NotizModel->addJoin('public.tbl_notiz_typ', 'public.tbl_notiz.typ = public.tbl_notiz_typ.typ_kurzbz');
$this->NotizModel->addJoin('public.tbl_benutzer verfasserbenutzer', 'tbl_notiz.verfasser_uid = verfasserbenutzer.uid', 'LEFT');
$this->NotizModel->addJoin('public.tbl_person verfasserperson', 'verfasserbenutzer.person_id = verfasserperson.person_id', 'LEFT');
$this->NotizModel->addJoin('public.tbl_benutzer bearbeiterbenutzer', 'tbl_notiz.bearbeiter_uid = bearbeiterbenutzer.uid', 'LEFT');
$this->NotizModel->addJoin('public.tbl_person bearbeiterperson', 'bearbeiterbenutzer.person_id = bearbeiterperson.person_id', 'LEFT');
$this->NotizModel->addJoin('public.tbl_notizzuordnung notizzuordnung', 'tbl_notiz.notiz_id = notizzuordnung.notiz_id');
$notiz = $this->NotizModel->loadWhere(array('prestudent_id' => $prestudent_id));
$this->terminateWithSuccess(hasData($notiz) ? getData($notiz) : array());
}
public function rebuildTagsForTypeId()
{
$id = $this->input->post('id');
$typeId = $this->input->post('typeId');
$semester = $this->input->post('sem');
$result = $this->taglib->rebuildTagsForTypeId($typeId, $id, $semester);
if (isError($result))
return error ('Error occurred during updateAutomatedTags');
$this->terminateWithSuccess($result);
}
private function _setAuthUID()
{
$this->_uid = getAuthUID();
+4 -4
View File
@@ -418,10 +418,10 @@ function findResource($path, $resource, $subdir = false, $extraDir = null)
if (!function_exists('array_is_list')) {
function array_is_list(array $arr)
{
if ($arr === []) {
return true;
}
return array_keys($arr) === range(0, count($arr) - 1);
if ($arr === []) {
return true;
}
return array_keys($arr) === range(0, count($arr) - 1);
}
}
-22
View File
@@ -270,28 +270,6 @@ function absoluteJsImportUrl($relurl)
return $url;
}
/*
* Generate Css File Include if Extension contains file
*
* @param $relativeFilePath path relative to Extension public/css dir
*/
function generateCSSsIncludeIfExtensionCssExists($relativeFilePath)
{
$fsiterator = new FilesystemIterator(FHCPATH . 'application/extensions');
foreach ($fsiterator as $fsitem)
{
if(preg_match('/^FHC-Core-/', $fsitem->getBasename()))
{
$extensionfile = 'public/extensions/' . $fsitem->getBasename()
. '/css/' . $relativeFilePath;
if(is_readable(FHCPATH . $extensionfile))
{
generateCSSsInclude($extensionfile);
}
}
}
}
/*
* Manipulate CI views includes Array to load
* - public/js/FhcApps.js via customJSs and
+203 -124
View File
@@ -1,12 +1,21 @@
<?php
/**
* FH-Complete
/* Copyright (C) 2025 fhcomplete.net
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @package FHC-Helper
* @author FHC-Team
* @copyright Copyright (c) 2022 fhcomplete.net
* @license GPLv3
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
@@ -121,90 +130,32 @@ class AkteLib
* Gets akte data and associated dms data by akte Id
* Returns success with akte and dms data or error
*/
public function get($akte_id)
public function getByAkteId($akte_id, $dokument_kurzbz = null, $archiv = null, $signiert = null, $stud_selfservice = null)
{
// get Akte data
$this->_ci->AkteModel->addSelect('person_id, dokument_kurzbz, mimetype, erstelltam, titel, bezeichnung,
gedruckt, uid, dms_id, nachgereicht, nachgereicht_am, anmerkung,
ausstellungsnation, formal_geprueft_amum, archiv, signiert,
stud_selfservice, akzeptiertamum, insertvon, insertamum, updatevon, updateamum');
$this->_ci->AkteModel->load($akte_id);
$akteResult = $this->_ci->AkteModel->load($akte_id);
if (isError($akteResult)) return $akteResult;
if (!hasData($akteResult)) return error("Akte not found");
$resultObject = getData($akteResult)[0];
// set properties with same name in Akte and Dms table
$resultObject->akte_mimetype = $resultObject->mimetype;
// get dms data
$dmsResult = $this->_ci->dmslib->getLastVersion($resultObject->dms_id);
if (isError($dmsResult)) return $dmsResult;
// properties to retrieve from dms
$dmsProperties = array('version', 'filename', 'mimetype', 'name', 'beschreibung', 'cis_suche', 'schlagworte', DmsLib::FILE_CONTENT_PROPERTY);
// set dms properties
if (hasData($dmsResult))
{
$dmsData = getData($dmsResult);
foreach ($dmsProperties as $dmsProperty)
{
$resultObject->{$dmsProperty} = $dmsData->{$dmsProperty};
}
}
else
{
// set null if no dms result found
foreach ($dmsProperties as $dmsProperty)
{
$resultObject->{$dmsProperty} = null;
}
}
// return the object containing akte and dms data
return success($resultObject);
return $this->_get(
$akte_id,
null, // person_id
$dokument_kurzbz,
$archiv,
$signiert,
$stud_selfservice
);
}
/**
* Gets Akte data and associated dms data by person Id and dokument_kurzbz
* Returns success with result array with akte and dms data or error
*/
public function getByPersonIdAndDocumentType($person_id, $dokument_kurzbz)
public function getByPersonId($person_id, $dokument_kurzbz = null, $archiv = null, $signiert = null, $stud_selfservice = null)
{
// load all Akte entries for given person and dokument_kurzbz
$this->_ci->AkteModel->addSelect('akte_id');
$akteResult = $this->_ci->AkteModel->loadWhere(
array(
'person_id' => $person_id,
'dokument_kurzbz' => $dokument_kurzbz
)
return $this->_get(
null, // akte_id
$person_id,
$dokument_kurzbz,
$archiv,
$signiert,
$stud_selfservice
);
if (!hasData($akteResult)) return error("Akte not found");
$akteData = getData($akteResult);
$resultArr = array();
// for each found akte entry
foreach ($akteData as $akte)
{
// get dms and akte data from akte Id
$getAkteDmsResult = $this->get($akte->akte_id);
if (isError($getAkteDmsResult)) return $getAkteDmsResult;
$resultArr[] = getData($getAkteDmsResult);
}
// return all found entries
return success($resultArr);
}
/**
@@ -213,56 +164,184 @@ class AkteLib
*/
public function remove($akte_id)
{
// get dms_id for akte
return $this->_remove($akte_id, null, null);
}
/**
* Removes Akte by $person_id and $dms_id, removes all associated dms entries and versions, and deletes all associated files
* Returns success with removed version numbers or error
*/
public function removeByPersonIdAndDmsId($person_id, $dms_id)
{
return $this->_remove(null, $person_id, $dms_id);
}
/**
*
*/
private function _get($akte_id = null, $person_id = null, $dokument_kurzbz = null, $archiv = null, $signiert = null, $stud_selfservice = null)
{
$dbModel = new DB_Model();
$query = 'SELECT akte_id,
person_id,
dokument_kurzbz,
inhalt,
CASE WHEN inhalt is not null THEN true ELSE false END as inhalt_vorhanden,
mimetype,
erstelltam,
gedruckt,
titel,
bezeichnung,
updateamum,
updatevon,
insertamum,
insertvon,
uid,
dms_id,
nachgereicht,
anmerkung,
titel_intern,
anmerkung_intern,
nachgereicht_am,
ausstellungsnation,
formal_geprueft_amum,
archiv,
signiert,
stud_selfservice,
akzeptiertamum
FROM public.tbl_akte
WHERE TRUE';
// Query parameters
$paramArray = array();
// akte_id
if (is_numeric($akte_id) || is_array($akte_id))
{
$paramArray[] = $akte_id;
if (is_numeric($akte_id)) $query .= ' AND akte_id = ?';
if (is_array($akte_id)) $query .= ' AND akte_id IN ?';
}
// person_id
if (is_numeric($person_id) || is_array($person_id))
{
$paramArray[] = $person_id;
if (is_numeric($person_id)) $query .= ' AND person_id = ?';
if (is_array($person_id)) $query .= ' AND person_id IN ?';
}
// dokument_kurzbz
if (!isEmptyString($dokument_kurzbz))
{
$paramArray[] = $dokument_kurzbz;
$query .= ' AND dokument_kurzbz = ?';
}
// archiv
if (is_bool($archiv))
{
$paramArray[] = $archiv;
$query .= ' AND archiv = ?';
}
// signiert
if (is_bool($signiert))
{
$paramArray[] = $signiert;
$query .= ' AND signiert = ?';
}
// stud_selfservice
if (is_bool($stud_selfservice))
{
$paramArray[] = $stud_selfservice;
$query .= ' AND stud_selfservice = ?';
}
// If no parameters has been provided exit
if (isEmptyArray($paramArray)) return error('Called without giving any parameter');
// Loads data from DB
$akteResult = $dbModel->execReadOnlyQuery($query, $paramArray);
// If error or data not found then exit
if (isError($akteResult)) return $akteResult;
if (!hasData($akteResult)) return error('Akte not found');
// For each record from the akte
foreach (getData($akteResult) as $resultObject)
{
// get dms data
$dmsResult = $this->_ci->dmslib->getLastVersion($resultObject->dms_id);
if (isError($dmsResult)) return $dmsResult;
// properties to retrieve from dms
$dmsProperties = array('version', 'filename', 'mimetype', 'name', 'beschreibung', 'cis_suche', 'schlagworte');
// set dms properties
if (hasData($dmsResult))
{
$dmsData = getData($dmsResult)[0];
foreach ($dmsProperties as $dmsProperty)
{
// If the property is _not_ 'mimetype' _or_
// If the mimetype from the akte table is null then overwrite it with the one from the DMS
if ($dmsProperty != 'mimetype' || ($dmsProperty == 'mimetype' && $resultObject->{$dmsProperty} == null))
{
$resultObject->{$dmsProperty} = $dmsData->{$dmsProperty};
}
}
}
else
{
// Set null if no dms result found
foreach ($dmsProperties as $dmsProperty)
{
if ($dmsProperty != 'mimetype') $resultObject->{$dmsProperty} = null;
}
}
}
// return the object containing akte and dms data
return success(getData($akteResult));
}
/**
* Removes Akte by akte Id, person id and/or dms id
* Removes all associated dms entries and versions, and deletes all associated files
* Returns success with removed version numbers or error
*/
private function _remove($akte_id = null, $person_id = null, $dms_id = null)
{
// Get dms_id for akte
$this->_ci->AkteModel->addSelect('akte_id');
$this->_ci->AkteModel->addSelect('dms_id');
$akteResult = $this->_ci->AkteModel->load($akte_id);
$paramArray = array();
if (is_numeric($akte_id)) $paramArray['akte_id'] = $akte_id;
if (is_numeric($person_id)) $paramArray['person_id'] = $person_id;
if (is_numeric($dms_id)) $paramArray['dms_id'] = $dms_id;
$akteResult = $this->_ci->AkteModel->loadWhere($paramArray);
if (isError($akteResult)) return $akteResult;
if (!hasData($akteResult)) return error("Akte not found");
if (!hasData($akteResult)) return error('Akte not found');
$dms_id = getData($akteResult)[0]->dms_id;
$error = null;
// Delete Akte
$deleteResult = $this->_ci->AkteModel->delete(getData($akteResult)[0]->akte_id);
// Start DB transaction to avoid deleting only part of the data
$this->_ci->db->trans_begin();
if (isError($deleteResult)) return $deleteResult;
// delete Akte
$deleteResult = $this->_ci->AkteModel->delete($akte_id);
// Remove all dms entry for dms of the akte
$removeAllResult = $this->_ci->dmslib->removeAll(getData($akteResult)[0]->dms_id);
if (isError($deleteResult))
{
$error = $deleteResult;
}
else
{
// remove all dms entry for dms of the akte
$removeAllResult = $this->_ci->dmslib->removeAll($dms_id);
if (isError($removeAllResult))
$error = $removeAllResult;
}
// Transaction complete!
$this->_ci->db->trans_complete();
// Check if everything went ok during the transaction
if ($this->_ci->db->trans_status() === false || isset($error))
{
$this->_ci->db->trans_rollback();
// return occured error
if (isset($error))
return $error;
else
return error("Error occured when deleting, rolled back");
}
else
{
$this->_ci->db->trans_commit();
// return removed dms entry data
return $removeAllResult;
}
return $removeAllResult;
}
}
+118 -523
View File
@@ -1,12 +1,21 @@
<?php
/**
* FH-Complete
/* Copyright (C) 2025 fhcomplete.net
*
* 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 2 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, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @package FHC-Helper
* @author FHC-Team
* @copyright Copyright (c) 2022 fhcomplete.net
* @license GPLv3
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
@@ -15,24 +24,17 @@ use \stdClass as stdClass;
class DmsLib
{
const FILE_CONTENT_PROPERTY = 'file_content'; // property name for file content
const DMS_SYS_NAME = 'DMS System';
private $_ci; // code igniter instance
private $_who; // who added this document
/**
* Object initialization
*/
public function __construct($params = null)
public function __construct()
{
$this->_ci =& get_instance();
// Set the the _who property
$this->_who = 'DMS system'; // default
// It is possible to set it using the who parameter
if (!isEmptyArray($params) && isset($params['who']) && !isEmptyString($params['who'])) $this->_who = $params['who'];
$this->_ci->load->model('crm/Akte_model', 'AkteModel'); // deprecated, should not be used here!
$this->_ci->load->model('content/Dms_model', 'DmsModel');
$this->_ci->load->model('content/DmsVersion_model', 'DmsVersionModel');
$this->_ci->load->model('content/DmsFS_model', 'DmsFSModel');
@@ -46,69 +48,85 @@ class DmsLib
* Returns success info of added dms entry (dms_id, version, filename) or error
*/
public function add(
$name, $mimetype, $fileHandle, // Required parameters
$kategorie_kurzbz = null, $dokument_kurzbz = null, $beschreibung = null, $cis_suche = false, $schlagworte = null
// Required parameters
$name, $mimetype, $fileHandle,
// Optional parameters
$kategorie_kurzbz = null, $dokument_kurzbz = null, $beschreibung = null, $cis_suche = false, $schlagworte = null, $insertvon = self::DMS_SYS_NAME
)
{
// create unique filename, using original document name to detect file extension
$filename = $this->_getUniqueFilename($name);
// If the file handle is not valid
if ($fileHandle === false) return error('Was not possible to open the given file');
// copy file from fileHandle to dms folder
$copyFileResult = $this->_copyFile($fileHandle, $filename);
// Create unique filename, using original document name to detect file extension
$filename = $this->_getUniqueFilename($name);
if (isError($copyFileResult)) return $copyFileResult;
// Copy file from fileHandle to dms folder
$copyFileResult = $this->_copyFile($fileHandle, $filename);
// if file written successful, insert dms
$dmsResult = $this->_ci->DmsModel->insert(
array(
'kategorie_kurzbz' => $kategorie_kurzbz,
'dokument_kurzbz' => $dokument_kurzbz
)
// If an error occrured while copying the file
if (isError($copyFileResult)) return $copyFileResult;
// Insert the new DMS
$dmsResult = $this->_ci->DmsModel->insert(
array(
'kategorie_kurzbz' => $kategorie_kurzbz,
'dokument_kurzbz' => $dokument_kurzbz
)
);
// If an error occurred
if (isError($dmsResult)) return $dmsResult;
// If a DMS in the previous insert returned the new PK value
if (hasData($dmsResult))
{
$dms_id = getData($dmsResult);
// Insert the DMS version
$dmsVersion = array(
'dms_id' => $dms_id,
'version' => 0,
'filename' => $filename,
'mimetype' => $mimetype,
'name' => $name,
'beschreibung' => $beschreibung,
'cis_suche' => $cis_suche,
'schlagworte' => $schlagworte,
'insertvon' => $insertvon,
'insertamum' => date('Y-m-d H:i:s')
);
if (isError($dmsResult)) return $dmsResult;
$dmsVersionResult = $this->_ci->DmsVersionModel->insert($dmsVersion);
if (hasData($dmsResult))
{
$dms_id = getData($dmsResult);
$version = 0;
// If an error occured
if (isError($dmsVersionResult)) return $dmsVersionResult;
// insert dms version
$dmsVersion = array(
'dms_id' => $dms_id,
'version' => $version,
'filename' => $filename,
'mimetype' => $mimetype,
'name' => $name,
'beschreibung' => $beschreibung,
'cis_suche' => $cis_suche,
'schlagworte' => $schlagworte,
'insertvon' => $this->_who,
'insertamum' => date('Y-m-d H:i:s')
);
// Return dms info
$resObj = new stdClass();
$resObj->dms_id = $dms_id;
$resObj->version = 0;
$resObj->filename = $filename;
$dmsVersionResult = $this->_ci->DmsVersionModel->insert($dmsVersion);
if (isError($dmsVersionResult)) return $dmsVersionResult;
// return dms info
$resObj = new stdClass();
$resObj->dms_id = $dms_id;
$resObj->version = $version;
$resObj->filename = $filename;
return success($resObj);
}
else
return error("error when inserting DMS");
return success($resObj);
}
else
return success();
}
/**
* Writes a new file with content of fileHandle, adds a new dms version (max version number + 1) for the written file
* Returns success with info of added dms version (version, filename) or error
*/
public function addNewVersion($dms_id, $fileHandle, $name = null, $mimetype = null, $beschreibung = null, $cis_suche = false, $schlagworte = null)
public function addNewVersion(
// Required parameters
$dms_id, $fileHandle,
// Optional parameters
$name = null, $mimetype = null, $beschreibung = null, $cis_suche = false, $schlagworte = null, $insertvon = self::DMS_SYS_NAME
)
{
// If the file handle is not valid
if ($fileHandle === false) return error('Was not possible to open the given file');
// get the latest version
$lastVersionResult = $this->getLastVersion($dms_id);
@@ -141,7 +159,7 @@ class DmsLib
'beschreibung' => isset($beschreibung) ? $beschreibung : $lastVersion->beschreibung,
'cis_suche' => isset($cis_suche) ? $cis_suche : $lastVersion->cis_suche,
'schlagworte' => isset($schlagworte) ? $schlagworte : $lastVersion->schlagworte,
'insertvon' => $this->_who,
'insertvon' => $insertvon,
'insertamum' => date('Y-m-d H:i:s')
);
@@ -157,7 +175,7 @@ class DmsLib
return success($resObj);
}
else
return error("last version not found");
return success();
}
/**
@@ -167,6 +185,9 @@ class DmsLib
*/
public function updateLastVersion($dms_id, $fileHandle, $name = null, $mimetype = null, $beschreibung = null, $cis_suche = false, $schlagworte = null)
{
// If the file handle is not valid
if ($fileHandle === false) return error('Was not possible to open the given file');
// get the latest version
$lastVersionResult = $this->getLastVersion($dms_id);
@@ -208,12 +229,12 @@ class DmsLib
return success($resObj);
}
else
return error("last version not found");
return success();
}
/**
* Gets dms version with highest number
* Returns success with dms data and fileHandle with file content or error
* Returns success with dms data or error
*/
public function getLastVersion($dms_id)
{
@@ -237,12 +258,12 @@ class DmsLib
return $this->getVersion($dms_id, $lastDmsVersion);
}
else
return error("Dms last version not found");
return success();
}
/**
* Gets specified dms version
* Returns success with dms data and fileHandle with file content or error
* Returns success with dms data or error
*/
public function getVersion($dms_id, $version)
{
@@ -254,34 +275,7 @@ class DmsLib
)
);
if (isError($dmsVersionResult)) return $dmsVersionResult;
if (hasData($dmsVersionResult))
{
$dmsVersion = getData($dmsVersionResult)[0];
// get file content as file pointer
$fileHandleResult = $this->_ci->DmsFSModel->openRead($dmsVersion->filename);
if (isError($fileHandleResult)) return $fileHandleResult;
if (hasData($fileHandleResult))
{
$fileHandle = getData($fileHandleResult);
$dmsVersion->{self::FILE_CONTENT_PROPERTY} = $fileHandle;
// close file pointer
$closeResult = $this->_ci->DmsFSModel->close($fileHandle);
if (isError($closeResult)) return $closeResult;
return success($dmsVersion);
}
else
return error("File could not be opened");
}
else
return error("Dms version not found");
return $dmsVersionResult;
}
/**
@@ -420,6 +414,34 @@ class DmsLib
return success($removeVersionResultObj);
}
/**
* Get info from the DMS to be provided to the FHC_Controller->outputFile
*/
public function getOutputFileInfo($dms_id, $file_name = '', $disposition = 'attachment')
{
// Loads the last DMS version from database
$lastVersionResult = $this->getLastVersion($dms_id);
// If an error occurred then return it
if (isError($lastVersionResult)) return $lastVersionResult;
// If has been found
if (hasData($lastVersionResult))
{
$lastVersion = getData($lastVersionResult)[0];
$fileObj = new stdClass();
$fileObj->file = DMS_PATH.$lastVersion->filename;
$fileObj->name = isEmptyString($file_name) ? $lastVersion->name : $file_name;
$fileObj->mimetype = $lastVersion->mimetype;
$fileObj->disposition = $disposition;
return success($fileObj);
}
return success();
}
// -----------------------------------------------------------------------------------------------------------
// Private methods
@@ -474,432 +496,5 @@ class DmsLib
return $uniqueFilename;
}
// -----------------------------------------------------------------------------------------------------------
// Deprecated methods, not to be used
/**
* Load a DMS Document.
* If no version is particularly given, the latest version is loaded.
*
* @param $dms_id
* @param integer $version
* @return array
*/
public function load($dms_id, $version = null)
{
if (is_numeric($dms_id))
{
$this->_ci->DmsModel->addJoin('campus.tbl_dms_version', 'dms_id');
$this->_ci->DmsModel->addOrder('version', 'DESC');
$this->_ci->DmsModel->addLimit(1);
if (!is_numeric($version))
{
return $this->_ci->DmsModel->load($dms_id);
}
else
{
return $this->_ci->DmsModel->loadWhere(array('dms_id' => $dms_id, 'version' => $version));
}
}
return error('The parameter DMS ID must be a number');
}
/**
* Read a DMS Document from the Filesystem
* @param int $dms_id ID of the Document.
* @param int $version The version of the Document (latest if null).
* @return object success or error
*/
public function read($dms_id, $version = null)
{
$result = error('Wrong dms_id parameter');
if (isset($dms_id))
{
$this->_ci->DmsModel->addJoin('campus.tbl_dms_version', 'dms_id');
$this->_ci->DmsModel->addOrder('version', 'DESC');
$this->_ci->DmsModel->addLimit(1);
if (!isset($version))
{
$result = $this->_ci->DmsModel->load($dms_id);
}
else
{
$result = $this->_ci->DmsModel->loadWhere(array('dms_id' => $dms_id, 'version' => $version));
}
// If a dms has been found
if (hasData($result))
{
$resultFS = $this->_ci->DmsFSModel->readBase64(getData($result)[0]->filename);
if (isError($resultFS)) return $resultFS; // if an error occurred return it
$result->retval[0]->{self::FILE_CONTENT_PROPERTY} = getData($resultFS);
}
}
return $result;
}
/**
* Get all accepted Documents of a Person
*
* @param int $person_id ID of the person.
* @param string $dokument_kurzbz Type of document.
* @param bool $no_file If null then loads also the content.
* @return object success or error
*/
public function getAktenAcceptedDms($person_id, $dokument_kurzbz = null, $no_file = null)
{
$result = $this->_ci->AkteModel->getAktenAcceptedDms($person_id, $dokument_kurzbz);
if (hasData($result) && $no_file == null)
{
for ($i = 0; $i < count(getData($result)); $i++)
{
$resultFS = $this->_ci->DmsFSModel->readBase64(getData($result)[$i]->filename);
if (isError($resultFS)) return $resultFS; // if an error occurred return it
$result->retval[$i]->{self::FILE_CONTENT_PROPERTY} = getData($resultFS);
}
}
return $result;
}
/**
* Uploads a document and saves it to DMS
* @param $dms DMS assoc array
* @param $field_name Name of the HTML uploadfile input name attribute
* @param array $allowed_types Default: all. Param example: array(jpg, pdf)
* @return array
*/
public function upload($dms, $field_name, $allowed_types = array('*'))
{
// Init upload configs
$this->_loadUploadLibrary($allowed_types);
if (!$this->_ci->upload->do_upload($field_name))
{
return error($this->_ci->upload->display_errors());
}
$upload_data = $this->_ci->upload->data(); // data about the uploaded file
// Insert to DMS table
$insDmsResult = $this->_ci->DmsModel->insert($this->_ci->DmsModel->filterFields($dms));
if (isError($insDmsResult)) return $insDmsResult;
$upload_data['dms_id'] = getData($insDmsResult);
if(isset($upload_data['file_type']) && !isset($dms['mimetype']))
$dms['mimetype'] = $upload_data['file_type'];
// Insert DMS version
$insVersionResult = $this->_ci->DmsVersionModel->insert(
$this->_ci->DmsVersionModel->filterFields(
$dms,
$upload_data['dms_id'],
$upload_data['file_name']
)
);
if (isError($insVersionResult)) return $insVersionResult;
// Return result of uploaded data
return success($upload_data);
}
/**
* Download a document.
*
* @param $dms_id
* @param string $filename $filename If String is given, it will be used as filename on download
* @param string $disposition [inline | attachment]
* Inline opens doc in new tab. Attachment displays download dialog box.
*/
public function download($dms_id, $filename = null, $disposition = 'inline')
{
// Retrieves info about the given dms
$fileInfoResult = $this->getFileInfo($dms_id);
if (isError($fileInfoResult)) return error(getError($fileInfoResult));
// If data have been found
if (hasData($fileInfoResult))
{
$fileObj = getData($fileInfoResult);
// Change filename, if filename is provided
if (!isEmptyString($filename)) $fileObj->name = $filename;
// Add file disposition if disposition has a valid value
if ($disposition == 'attachment' || $disposition == 'inline')
{
$fileObj->disposition = $disposition;
}
return success($fileObj);
}
// If no data have been found then return an empty success
return success();
}
/**
* Get file information.
*
* @param $dms_id
* @param integer $version
* @return array with File Object.
*/
public function getFileInfo($dms_id, $version = null)
{
// Checks the dms_id parameter
if (!is_numeric($dms_id)) return error('Wrong parameter');
// Load DMS from database
$result = $this->load($dms_id, $version);
if (isError($result)) return error(getError($result));
// If data have been found
if (hasData($result))
{
// Store file information in fileObj
$fileObj = new stdClass();
$fileObj->filename = getData($result)[0]->filename;
$fileObj->file = DMS_PATH.getData($result)[0]->filename;
$fileObj->name = getData($result)[0]->name; // original user filename
$fileObj->mimetype = getData($result)[0]->mimetype;
return success($fileObj);
}
// If no data have been found return an empty success
return success();
}
/**
* Saves a Document
* @param object $dms DMS Object ot be saved.
* @return object
*/
public function save($dms)
{
$result = null;
if (isset($dms['new']) && $dms['new'] == true)
{
// Remove new parameter to avoid DB insert errors
unset($dms['new']);
$result = $this->_saveFileOnInsert($dms);
if (isSuccess($result))
{
$filename = getData($result);
if (isset($dms['dms_id']) && $dms['dms_id'] != '')
{
$result = $this->_ci->DmsVersionModel->insert(
$this->_ci->DmsVersionModel->filterFields($dms, $dms['dms_id'], $filename)
);
}
else
{
$result = $this->_ci->DmsModel->insert($this->_ci->DmsModel->filterFields($dms));
if (isSuccess($result))
{
$result = $this->_ci->DmsVersionModel->insert(
$this->_ci->DmsVersionModel->filterFields($dms, getData($result), $filename)
);
}
}
}
}
else
{
$result = $this->_saveFileOnUpdate($dms);
if (isSuccess($result))
{
$result = $this->_ci->DmsModel->update($dms['dms_id'], $this->_ci->DmsModel->filterFields($dms));
if (isSuccess($result))
{
$result = $this->_ci->DmsVersionModel->update(
array(
$dms['dms_id'],
$dms['version']
),
$this->_ci->DmsVersionModel->filterFields($dms)
);
}
}
}
return $result;
}
/**
* Deletes a Akte of a Person
* @param int $person_id ID of the person.
* @param int $dms_id Id of the Document.
* @return object
*/
public function delete($person_id, $dms_id)
{
$result = null;
// If the parameters are valid
if (is_numeric($person_id) && is_numeric($dms_id))
{
// Start DB transaction
$this->_ci->db->trans_start(false);
// Get akte_id from table tbl_akte
$result = $this->_ci->AkteModel->loadWhere(array('person_id' => $person_id, 'dms_id' => $dms_id));
if (isSuccess($result))
{
// Delete all entries in tbl_akte
for ($i = 0; $i < count(getData($result)); $i++)
{
$this->_ci->AkteModel->delete(getData($result)[$i]->akte_id);
}
// Get all filenames related to this dms
$resultFileNames = $this->_ci->DmsVersionModel->loadWhere(array('dms_id' => $dms_id));
if (isSuccess($resultFileNames))
{
// Delete from tbl_dms_version
$result = $this->_ci->DmsVersionModel->delete(array('dms_id' => $dms_id));
if (isSuccess($result))
{
// Delete from tbl_dms
$result = $this->_ci->DmsModel->delete($dms_id);
}
}
}
// Transaction complete!
$this->_ci->db->trans_complete();
// Check if everything went ok during the transaction
if ($this->_ci->db->trans_status() === false || isError($result))
{
$this->_ci->db->trans_rollback();
$result = error('An error occurred while performing a delete operation', EXIT_ERROR);
}
else
{
$this->_ci->db->trans_commit();
$result = success('Dms successfully removed from DB');
}
// If everything is ok
if (isSuccess($result))
{
// Remove all files related to this person and dms
for ($i = 0; $i < count(getData($resultFileNames)); $i++)
{
$this->_ci->DmsFSModel->removeBase64(getData($resultFileNames)[$i]->filename);
}
}
}
else
{
$result = error('Invalid parameters');
}
return $result;
}
/**
* Loads the Content of an akte
* @param int $akte_id Id of the akte.
* @return object with document content or error
*/
public function getAkteContent($akte_id)
{
$akte = $this->_ci->AkteModel->load($akte_id);
if (hasData($akte))
{
if (getData($akte)[0]->inhalt != '')
{
return success(base64_decode(getData($akte)[0]->inhalt));
}
elseif (getData($akte)[0]->dms_id != '')
{
$dmscontent = $this->read(getData($akte)[0]->dms_id);
if (isSuccess($dmscontent))
{
return success(base64_decode(getData($dmscontent)[0]->file_content));
}
else
{
return error(getError($dmscontent));
}
}
else
{
return error('No Content available');
}
}
else
{
return error(getError($akte));
}
}
/**
* Saves the Content of a DMS in the Filesystem
* @param object $dms DMS object to be saved.
* @return object
*/
private function _saveFileOnInsert($dms)
{
$filename = uniqid().'.'.pathinfo($dms['name'], PATHINFO_EXTENSION);
$result = $this->_ci->DmsFSModel->writeBase64($filename, $dms['file_content']);
if (isSuccess($result))
{
$result = success($filename);
}
return $result;
}
/**
* Updates the File in the Filesystem
* @param object $dms DMS object to update.
* @return object
*/
private function _saveFileOnUpdate($dms)
{
$result = null;
if (isset($dms['version']))
{
$result = $this->read($dms['dms_id'], $dms['version']);
if (hasData($result))
{
$result = $this->_ci->DmsFSModel->writeBase64(getData($result)[0]->filename, $dms['file_content']);
}
}
return $result;
}
/**
* Loads the upload library of CI
*/
private function _loadUploadLibrary($allowed_types)
{
$config = array();
$config['upload_path'] = DMS_PATH;
$config['allowed_types'] = implode('|', $allowed_types);
$config['overwrite'] = true;
$config['file_name'] = uniqid().'.pdf';
$this->_ci->load->library('upload', $config);
$this->_ci->upload->initialize($config);
}
}
+37 -236
View File
@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2024 fhcomplete.net
/* Copyright (C) 2025 fhcomplete.net
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -34,15 +34,11 @@ use SimpleXMLElement as SimpleXMLElement;
* modifiing said data (sign()/setXMLTag_archivierbar()) or adding
* images (addImage()) and then call output() and close().
* Now the create, output and close functions are combined into one function and adding data and images is done via parameters.
* There are now two functions getContent() and showContent() where showContent() equals to output(false) and getContent equals to output(true)
* Instead of calling addDataArray, addDataXML or addDataURL just call
* getDataArray, getDataXML or getDataURL respectevily and use the return
* value as $xml_data parameter in the showContent and getContent calls.
* value as $xml_data parameter in the getContent call.
* Instead of calling addImages just create an array and pass it as $images
* parameter to the showContent/getContent function.
* The old setFilename() function is now a parameter in showContent(). It is
* not needed in getContent() since that function does not do anything that
* requires a filename.
* parameter to the getContent function.
* To get/show a signed document just pass a valid uid as $sign_user
* parameter.
*
@@ -63,21 +59,10 @@ use SimpleXMLElement as SimpleXMLElement;
* 'name' => $imagename,
* 'contenttype' => $imagecontenttype
* ]];
* $this->documentexportlib->showContent(
* $filename,
* $vorlage,
* $xml_data,
* $oe_kurzbz,
* $version,
* $outputformat,
* null,
* null,
* $images
* );
*/
class DocumentExportLib
{
private $unoconv_version;
private $_ci;
/**
* Constructor
@@ -85,33 +70,14 @@ class DocumentExportLib
public function __construct()
{
// Gets CI instance
$this->ci =& get_instance();
$this->_ci =& get_instance();
// Load Phrases
$this->ci->load->library('PhrasesLib', ['document_export', null], 'documentExportPhrases');
// Load phrases
$this->_ci->load->library('PhrasesLib', ['document_export', null], 'DocumentExportPhrases');
// Which document converter has to be used
if (defined('DOCSBOX_ENABLED') && DOCSBOX_ENABLED === true)
{
// Use docsbox!!
}
else
{
exec('unoconv --version', $ret_arr);
if(isset($ret_arr[0]))
{
$hlp = explode(' ', $ret_arr[0]);
if(isset($hlp[1]))
{
$this->unoconv_version = $hlp[1];
}
else
show_error($this->ci->documentExportPhrases->t("document_export", "error_unoconv_version"));
}
else
show_error($this->ci->documentExportPhrases->t("document_export", "error_unoconv"));
}
// Load libraries
$this->_ci->load->library('DocumentLib');
$this->_ci->load->library('SignatureLib');
}
/**
@@ -172,7 +138,7 @@ class DocumentExportLib
$xml_data = new DOMDocument;
if (!$xml_data->load($xml_url))
return error($this->ci->documentExportPhrases->t("document_export", "error_xml_load", [
return error($this->_ci->DocumentExportPhrases->t("document_export", "error_xml_load", [
"url" => $xml_url,
"xml" => $xml,
"params" => $params
@@ -236,7 +202,7 @@ class DocumentExportLib
$outputformat = $this->getDefaultOutputFormat($outputformat, $vorlage->mimetype);
$result = $this->createAndSignContent(
$createResult = $this->createAndSignContent(
$temp_folder,
$outputformat,
$vorlage,
@@ -247,118 +213,26 @@ class DocumentExportLib
$sign_user,
$sign_profile
);
if (isError($result)) {
if (isError($createResult)) {
$this->close($temp_folder, $source_folder);
return $result;
return $createResult;
}
$temp_filename = getData($result);
$temp_filename = getData($createResult);
$fsize = filesize($temp_filename);
$handle = fopen($temp_filename, 'r');
if (!$handle)
return error($this->ci->documentExportPhrases->t("document_export", "error_file_load"));
$result = fread($handle, $fsize);
return error($this->_ci->DocumentExportPhrases->t("document_export", "error_file_load"));
$fileContentResult = fread($handle, $fsize);
fclose($handle);
$this->close($temp_folder, $source_folder);
return success($result);
return success($fileContentResult);
}
/**
* Sets the headers and displays the Document.
* On failure the exit() function will be called
*
* @param string $filename
* @param stdClass $vorlage A db entry from tbl_vorlage
* @param DomDocument $xml_data
* @param string $oe_kurzbz
* @param integer|null $version (optional)
* @param string $outputformat (optional)
* @param string $sign_user (optional) Must be a valid uid
* @param string $sign_profile (optional) Signatureprofile for signing
* @param array $images (optional) Each element should have a property path, name & contenttype which are all strings
*
* @return void
*/
public function showContent(
$filename,
$vorlage,
$xml_data,
$oe_kurzbz,
$version = null,
$outputformat = null,
$sign_user = null,
$sign_profile = null,
$images = []
) {
$source_folder = getcwd();
$temp_folder = sys_get_temp_dir() . '/fhcunoconv-' . uniqid();
$outputformat = $this->getDefaultOutputFormat($outputformat, $vorlage->mimetype);
$result = $this->createAndSignContent(
$temp_folder,
$outputformat,
$vorlage,
$oe_kurzbz,
$version,
$xml_data,
$images,
$sign_user,
$sign_profile
);
if (isError($result)) {
$this->close($temp_folder, $source_folder);
exit(getError($result));
}
$temp_filename = getData($result);
$fsize = filesize($temp_filename);
$handle = fopen($temp_filename, 'r');
if (!$handle) {
$this->close($temp_folder, $source_folder);
exit($this->ci->documentExportPhrases->t("document_export", "error_file_load"));
}
if (headers_sent()) {
$this->close($temp_folder, $source_folder);
exit($this->ci->documentExportPhrases->t("document_export", "error_headers"));
}
switch ($outputformat) {
case 'pdf':
header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="' . $filename . '.pdf"');
header('Content-Length: ' . $fsize);
break;
case 'doc':
header('Content-type: application/vnd.ms-word');
header('Content-Disposition: attachment; filename="' . $filename . '.doc"');
header('Content-Length: ' . $fsize);
break;
case 'odt':
header('Content-type: application/vnd.oasis.opendocument.text');
header('Content-Disposition: attachment; filename="' . $filename . '.odt"');
header('Content-Length: ' . $fsize);
break;
default:
$this->close($temp_folder, $source_folder);
exit($this->ci->documentExportPhrases->t("document_export", "error_outputformat_missing"));
}
while (!feof($handle)) {
echo fread($handle, 8192);
}
fclose($handle);
$this->close($temp_folder, $source_folder);
}
/**
* Helper function for getContent and showContent.
* Helper function for getContent
* Creates the temp folder and calls create and sign functions.
*
* @param string $temp_folder
@@ -387,13 +261,13 @@ class DocumentExportLib
mkdir($temp_folder);
chdir($temp_folder);
$this->ci->load->model('system/Vorlagestudiengang_model', 'VorlagestudiengangModel');
$this->_ci->load->model('system/Vorlagestudiengang_model', 'VorlagestudiengangModel');
$result = $this->ci->VorlagestudiengangModel->getCurrent($vorlage->vorlage_kurzbz, $oe_kurzbz, $version);
$result = $this->_ci->VorlagestudiengangModel->getCurrent($vorlage->vorlage_kurzbz, $oe_kurzbz, $version);
if (isError($result))
return $result;
if (!hasData($result))
return error($this->ci->documentExportPhrases->t("document_export", "error_template_missing"));
return error($this->_ci->DocumentExportPhrases->t("document_export", "error_template_missing"));
$vorlage_stg = current(getData($result));
foreach ($vorlage_stg as $k => $v)
$vorlage->$k = $v;
@@ -437,7 +311,7 @@ class DocumentExportLib
{
$content_xsl = new DOMDocument();
if (!$content_xsl->loadXML($vorlage->text))
return error($this->ci->documentExportPhrases->t("document_export", "error_xsl_load"));
return error($this->_ci->DocumentExportPhrases->t("document_export", "error_xsl_load"));
$proc = new XSLTProcessor();
$proc->importStyleSheet($content_xsl);
@@ -454,7 +328,7 @@ class DocumentExportLib
if ($vorlage->style) {
$styles_xsl = new DOMDocument();
if (!$styles_xsl->loadXML($vorlage->style))
return error($this->ci->documentExportPhrases->t("document_export", "error_styles_load"));
return error($this->_ci->DocumentExportPhrases->t("document_export", "error_styles_load"));
$style_proc = new XSLTProcessor();
$style_proc->importStyleSheet($styles_xsl);
@@ -482,7 +356,7 @@ class DocumentExportLib
$tempname_zip = $temp_folder . '/out.zip';
if (!copy($zipfile, $tempname_zip))
return error($this->ci->documentExportPhrases->t("document_export", "error_file_copy"));
return error($this->_ci->DocumentExportPhrases->t("document_export", "error_file_copy"));
exec("zip $tempname_zip content.xml");
if (!is_null($styles_xsl))
@@ -502,7 +376,7 @@ class DocumentExportLib
$manifest_xml = new DOMDocument;
if (!$manifest_xml->loadXML($manifest))
return error($this->ci->documentExportPhrases->t("document_export", "error_manifest"));
return error($this->_ci->DocumentExportPhrases->t("document_export", "error_manifest"));
//root-node holen
$root = $manifest_xml->getElementsByTagName('manifest')->item(0);
@@ -529,42 +403,16 @@ class DocumentExportLib
clearstatcache();
$temp_filename = $temp_folder . '/out.' . $outputformat;
switch ($outputformat) {
case 'pdf':
case 'doc':
$ret = 0;
$temp_filename = $temp_folder . '/out.' . $outputformat;
$converResult = $this->_ci->documentlib->convert($tempname_zip, $temp_filename, $outputformat);
if (defined('DOCSBOX_ENABLED') && DOCSBOX_ENABLED === true) {
// Use docsbox
$this->ci->load->library("DocsboxLib");
$docboxlib = get_class($this->ci->docboxlib);
$ret = $docboxlib::convert($tempname_zip, $temp_filename, $outputformat);
} else {
// Use unoconv
// Unoconv Version 0.6 hat eine Bug wodurch die Berechtigungen des PDF/Doc nicht korrekt gesetzt
// werden. Deshalb wird dies hier speziell behandelt.
// Die 2. Variante hat den Vorteil dass hier eine bessere Fehlerbehandlung moeglich ist
if ($this->unoconv_version == '0.6')
$command = 'unoconv -e IsSkipEmptyPages=false -f ' . $outputformat . ' %2$s > %1$s';
else
$command = 'unoconv -e IsSkipEmptyPages=false -f ' . $outputformat . ' --output %s %s 2>&1';
$command = sprintf($command, $temp_filename, $tempname_zip);
exec($command, $out, $ret);
}
if ($ret)
return error($this->ci->documentExportPhrases->t("document_export", "error_conv_timeout"));
if (isError($converResult))
return error($this->_ci->DocumentExportPhrases->t('document_export', 'error_conv_timeout'));
break;
case 'odt':
default:
$temp_filename = $tempname_zip;
}
return success($temp_filename);
@@ -584,63 +432,15 @@ class DocumentExportLib
*/
protected function sign($temp_folder, $temp_filename, $outputformat, $user, $profile)
{
if ($outputformat != 'pdf')
return error($this->ci->documentExportPhrases->t("document_export", "error_sign_pdf"));
if ($outputformat != 'pdf') return error($this->_ci->DocumentExportPhrases->t('document_export', 'error_sign_pdf'));
// Load the File
$file_data = file_get_contents($temp_filename);
$signed_filename = $this->_ci->signaturelib->sign($temp_folder, $temp_filename, $user, $profile);
$data = new stdClass();
$data->document = base64_encode($file_data);
// If fine then return it
if (isSuccess($signed_filename)) return $signed_filename;
// Signatur Profil
if (!is_null($profile))
$data->profile = $profile;
else
$data->profile = SIGNATUR_DEFAULT_PROFILE;
// Username des Endusers der die Signatur angefordert hat
$data->user = $user;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, SIGNATUR_URL . '/' . SIGNATUR_SIGN_API);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 7);
curl_setopt($ch, CURLOPT_USERAGENT, "FH-Complete");
// SSL Zertifikatsprüfung deaktivieren
// Besser ist es das Zertifikat am Server zu installieren!
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$data_string = json_encode($data, JSON_FORCE_OBJECT);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Content-Length:' . mb_strlen($data_string),
'Authorization: Basic ' . base64_encode(SIGNATUR_USER . ":" . SIGNATUR_PASSWORD)
]);
$result = curl_exec($ch);
if (curl_errno($ch)) {
curl_close($ch);
return error($this->ci->documentExportPhrases->t("document_export", "error_sign_timeout"));
}
curl_close($ch);
$resultdata = json_decode($result);
// If it is success
if (isset($resultdata->error) && $resultdata->error == 0) {
$signed_filename = $temp_folder . '/signed.pdf';
file_put_contents($signed_filename, base64_decode($resultdata->retval));
return success($signed_filename);
}
// otherwise if it is an error
return error($resultdata->retval ?? $this->ci->documentExportPhrases->t("global", "unknown_error", ["error" => $result]));
// Otherwise it is an error
return error($this->_ci->DocumentExportPhrases->t('global', 'unknown_error', ['error' => getError($signed_filename)]));
}
/**
@@ -717,3 +517,4 @@ class DocumentExportLib
return 'pdf';
}
}
+25 -24
View File
@@ -4,7 +4,8 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
class DocumentLib
{
private $unoconv_version;
private $_ci;
private $_unoconv_version;
/**
* Constructor
@@ -12,7 +13,10 @@ class DocumentLib
public function __construct()
{
// Gets CI instance
$this->ci =& get_instance();
$this->_ci =& get_instance();
// Load phrases
$this->_ci->load->library('PhrasesLib', ['document_export', null], 'DocumentExportPhrases');
// Which document converter has to be used
if (defined('DOCSBOX_ENABLED') && DOCSBOX_ENABLED === true)
@@ -28,13 +32,13 @@ class DocumentLib
$hlp = explode(' ', $ret_arr[0]);
if(isset($hlp[1]))
{
$this->unoconv_version = $hlp[1];
$this->_unoconv_version = $hlp[1];
}
else
show_error('Could not get Unoconv Version');
show_error($this->_ci->DocumentExportPhrases->t('document_export', 'error_unoconv_version'));
}
else
show_error('Unoconv not found - Please install Unoconv');
show_error($this->_ci->DocumentExportPhrases->t('document_export', 'error_unoconv'));
}
}
@@ -56,7 +60,7 @@ class DocumentLib
case 'image/jpeg':
case 'image/jpg':
case 'image/pjpeg':
$this->_jpegtopdf($filename, $outFile);
$this->_jpegToPdf($filename, $outFile);
return success($outFile);
case 'application/vnd.oasis.opendocument.spreadsheet':
case 'application/msword':
@@ -72,23 +76,19 @@ class DocumentLib
else
{
// Unoconv Version 0.6 seems to fail on converting TXT Files
if ($this->unoconv_version == '0.6')
return error();
if ($this->_unoconv_version == '0.6') return error('Unoconv Version 0.6 does not convert TXT Files correctly');
}
// Convertion
$ret = $this->convert($filename, $outFile, 'pdf');
if(isSuccess($ret))
{
return success($outFile);
}
else
{
return error(getError($ret));
}
if(isSuccess($ret)) return success($outFile);
// Error
return $ret;
case 'application/pdf':
return success($filename);
default:
return error('Unknown Mimetype:'.$mimetype);
return error('Unknown Mimetype:' . $mimetype);
}
}
@@ -101,20 +101,20 @@ class DocumentLib
*/
public function mergePDF($files, $outFile)
{
$cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outFile ";
$cmd = 'gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outFile ';
$finfo = finfo_open(FILEINFO_MIME_TYPE);
// add all pdf files to the command
foreach ($files as $f)
{
$cmd .= $f." ";
$cmd .= $f.' ';
if (!file_exists($f))
{
return error("File not found: '$f'");
}
if (finfo_file($finfo, $f) != "application/pdf")
if (finfo_file($finfo, $f) != 'application/pdf')
{
return error("Wrong format(".finfo_file($finfo, $f)."): '$f'");
return error('Wrong format('.finfo_file($finfo, $f)."): '$f'");
}
}
@@ -144,13 +144,13 @@ class DocumentLib
// If it is set to use docsbox
if (defined('DOCSBOX_ENABLED') && DOCSBOX_ENABLED === true)
{
require_once(dirname(__FILE__).'/../application/libraries/DocsboxLib.php');
require_once(dirname(__FILE__).'/DocsboxLib.php');
$ret = DocsboxLib::convert($inFile, $outFile, $format);
}
else // otherwise use unoconv
{
if ($this->unoconv_version == '0.6')
if ($this->_unoconv_version == '0.6')
$command = 'unoconv -f %1$s %3$s > %2$s';
else
$command = 'unoconv -f %s --output %s %s 2>&1';
@@ -175,7 +175,7 @@ class DocumentLib
* @param string $outfile Path to Output (pdf) File.
* @return success or error object
*/
private function _jpegtopdf($filename, $outfile)
private function _jpegToPdf($filename, $outfile)
{
if (!file_exists($filename))
return error('File does not exists');
@@ -230,3 +230,4 @@ class DocumentLib
return true;
}
}
+77 -9
View File
@@ -36,15 +36,7 @@ class SignatureLib
try
{
// Dont send Document if it is bigger than 30 MB (Limit of Signature Server)
if (filesize($inputFileName) > 30000000)
{
$returnObject = new stdClass();
$returnObject->code = 1;
$returnObject->error = 1;
$returnObject->retval = 'File to big';
return $returnObject;
}
if (filesize($inputFileName) > 30000000) return $this->_returnObject(1, 1, 'File too big');
// Get the content of the given file
$inputFileContent = file_get_contents($inputFileName);
@@ -82,4 +74,80 @@ class SignatureLib
// Otherwise return a null as error
return null;
}
/**
*
*/
public function sign($temp_folder, $inputFileName, $user, $profile)
{
// Load the File
$file_data = file_get_contents($inputFileName);
$data = new stdClass();
$data->document = base64_encode($file_data);
// Signatur Profil
if (!is_null($profile))
$data->profile = $profile;
else
$data->profile = SIGNATUR_DEFAULT_PROFILE;
// Username des Endusers der die Signatur angefordert hat
$data->user = $user;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, SIGNATUR_URL . '/' . SIGNATUR_SIGN_API);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 7);
curl_setopt($ch, CURLOPT_USERAGENT, "FH-Complete");
// SSL Zertifikatsprüfung deaktivieren
// Besser ist es das Zertifikat am Server zu installieren!
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$data_string = json_encode($data, JSON_FORCE_OBJECT);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json',
'Content-Length:' . mb_strlen($data_string),
'Authorization: Basic ' . base64_encode(SIGNATUR_USER . ':' . SIGNATUR_PASSWORD)
]);
$result = curl_exec($ch);
if (curl_errno($ch)) {
curl_close($ch);
return $this->_returnObject(1, 1, 'CURL error');
}
curl_close($ch);
$resultdata = json_decode($result);
// If it is success
if (isset($resultdata->error) && $resultdata->error == 0)
{
$signed_filename = $temp_folder . '/signed.pdf';
file_put_contents($signed_filename, base64_decode($resultdata->retval));
return $this->_returnObject(0, 0, $signed_filename);
}
// Otherwise it is an error
return $this->_returnObject(1, 1, 'Error while signing the given document');
}
/**
*
*/
private function _returnObject($code, $error, $retval)
{
$returnObject = new stdClass();
$returnObject->code = $code;
$returnObject->error = $error;
$returnObject->retval = $retval;
return $returnObject;
}
}
+7 -278
View File
@@ -40,16 +40,13 @@ class StundenplanLib
* @return stdClass
* @access public
*/
public function getEventsUser($start, $end, $uid = null)
public function getEventsUser($start, $end)
{
$this->_ci =& get_instance();
$this->_ci->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
if (!$uid) {
$uid = getAuthUID();
}
$uid = getAuthUID();
if (is_null($uid))
return error("No UID");
@@ -114,7 +111,6 @@ class StundenplanLib
return $stundenplan_data;
$stundenplan_data = getData($stundenplan_data) ?? [];
$this->_ci->addMeta("stundenplanData", $stundenplan_data);
$function_error = $this->expandObjectInformation($stundenplan_data);
if ($function_error)
return $function_error;
@@ -221,7 +217,7 @@ class StundenplanLib
* @param string $ort_kurzbz
* @return stdClass
*/
public function getReservierungen($start_date, $end_date, $ort_kurzbz = '', $uid = null)
public function getReservierungen($start_date, $end_date, $ort_kurzbz = '')
{
$this->_ci =& get_instance();
@@ -232,14 +228,14 @@ class StundenplanLib
$this->_ci->load->model('ressource/Reservierung_model', 'ReservierungModel');
$this->_ci->load->model('ressource/Stundenplan_model', 'StundenplanModel');
$is_mitarbeiter = getData($this->_ci->MitarbeiterModel->isMitarbeiter($uid ?? getAuthUID()));
$is_mitarbeiter = getData($this->_ci->MitarbeiterModel->isMitarbeiter(getAuthUID()));
if ($is_mitarbeiter && empty($ort_kurzbz)) {
// request for personal lvplan show only reservations of logged in user
$reservierungen = $this->_ci->ReservierungModel->getReservierungenMitarbeiter($start_date, $end_date, $uid);
$reservierungen = $this->_ci->ReservierungModel->getReservierungenMitarbeiter($start_date, $end_date);
} else {
// querying the reservierungen
$reservierungen = $this->_ci->ReservierungModel->getReservierungen($start_date, $end_date, $ort_kurzbz, $uid);
$reservierungen = $this->_ci->ReservierungModel->getReservierungen($start_date, $end_date, $ort_kurzbz);
}
if (isError($reservierungen))
@@ -361,10 +357,7 @@ class StundenplanLib
if (isError($ort_content_object)) {
return error(getData($ort_content_object));
}
$ort_content_object_data = getData($ort_content_object);
$ort_content_object = (is_array($ort_content_object_data) && count($ort_content_object_data) > 0)
? $ort_content_object_data[0]
: null;
$ort_content_object = getData($ort_content_object)[0];
if($ort_content_object) {
$item->ort_content_id = $ort_content_object->content_id;
}
@@ -375,39 +368,6 @@ class StundenplanLib
$item->gruppe = $gruppe_obj_array;
$item->lektor = $lektor_obj_array;
$this->_ci->load->library('PermissionLib');
$berechtigt_begrenzt = $this->_ci->permissionlib->isBerechtigt('lehre/reservierung:begrenzt', 'sui');
$now = time();
$res_lektor_start = $this->jump_day($now, RES_TAGE_LEKTOR_MIN - 1);
$res_lektor_ende = mktime(0, 0, 0, date('m', $now), date('d', $now) + RES_TAGE_LEKTOR_BIS, date('Y', $now));
$start_date = is_numeric($item->beginn) ? $item->beginn : strtotime($item->beginn);
if (!date('w', $start_date)) {
$start_date = $this->jump_day($start_date, 1);
}
$start_date_str = date('Y-m-d', $start_date);
$res_lektor_start_str = date('Y-m-d', $res_lektor_start);
$res_lektor_ende_str = date('Y-m-d', $res_lektor_ende);
$show_delete = (
(
$berechtigt_begrenzt &&
(
(isset($item->insertvon) && $item->insertvon == getAuthUID()) ||
(isset($item->uids) && in_array(getAuthUID(), $item->uids))
)
) &&
$start_date_str >= $res_lektor_start_str &&
$start_date_str <= $res_lektor_ende_str
);
if ($show_delete)
$item->deletable = true;
else
$item->deletable = false;
}
}
@@ -485,237 +445,6 @@ class StundenplanLib
return success($ferienEventsFlattened);
}
public function getEventsStgOrg( $start, $end, $stg_kz, $sem, $verband, $gruppe)
{
$this->_ci =& get_instance();
$this->_ci->load->model('ressource/Stundenplan_model', 'StundenplanModel');
$stundenplan_data = $this->_ci->StundenplanModel->getStundenplanStudiengang($start, $end, $stg_kz, $sem, $verband, $gruppe);
if (isError($stundenplan_data))
return $stundenplan_data;
$stundenplan_data = getData($stundenplan_data) ?? [];
$function_error = $this->expandObjectInformation($stundenplan_data);
if ($function_error)
return $function_error;
return success($stundenplan_data);
}
public function addReservation($start, $end, $title, $beschreibung, $ort_kurzbz, $lektoren = null, $studiengang = null, $semester = null, $verband = null, $gruppe = null, $spezialgruppe = null)
{
$this->_ci =& get_instance();
$this->_ci->load->model('ressource/Stunde_model', 'StundeModel');
$this->_ci->load->model('ressource/Reservierung_model', 'ReservierungModel');
$this->_ci->load->model('ressource/stundenplandev_model', 'StundenplandevModel');
$this->_ci->load->model('ressource/stundenplan_model', 'StundenplanModel');
$this->_ci->load->library('PermissionLib');
$startTime = new DateTime($start);
$endTime = new DateTime($end);
$stunden = $this->_ci->StundeModel->loadWhere(array(
'beginn <' => $endTime->format('H:i:s'),
'ende >' => $startTime->format('H:i:s')
));
if (!hasData($stunden))
{
return error("Keine Stunden vorhanden");
}
$stunden = array_column(getData($stunden), 'stunde');
$this->_ci->StundenplandevModel->db->select('1');
$this->_ci->StundenplandevModel->db->where('datum', $startTime->format('Y-m-d'));
$this->_ci->StundenplandevModel->db->where('ort_kurzbz', $ort_kurzbz);
$this->_ci->StundenplandevModel->db->where_in('stunde', $stunden);
$stundenplandev_belegung = $this->_ci->StundenplandevModel->load();
$this->_ci->StundenplanModel->db->select('1');
$this->_ci->StundenplanModel->db->where('ort_kurzbz', $ort_kurzbz);
$this->_ci->StundenplanModel->db->where('datum', $startTime->format('Y-m-d'));
$this->_ci->StundenplanModel->db->where_in('stunde', $stunden);
$stundenplan_belegung = $this->_ci->StundenplanModel->load();
if ((hasData($stundenplandev_belegung) || hasData($stundenplan_belegung))
&& !$this->_ci->permissionlib->isBerechtigt('lehre/reservierungAdvanced'))
return error ('lvplan/bereitsReserviert');
$this->_ci->ReservierungModel->addSelect('stunde');
$reservation_hours = $this->_ci->ReservierungModel->loadWhere(array('datum' => $startTime->format('Y-m-d'), 'ort_kurzbz' => $ort_kurzbz));
if (isError($reservation_hours))
return $reservation_hours;
$reservation_hours = hasData($reservation_hours) ? array_column(getData($reservation_hours), 'stunde') : array();
if (!empty(array_intersect($stunden, $reservation_hours))
&& !$this->_ci->permissionlib->isBerechtigt('lehre/reservierungAdvanced'))
return error("lvplan/bereitsReserviert");
if (!empty($lektoren))
{
foreach ($lektoren as $lektor)
{
$insert = array('ort_kurzbz' => $ort_kurzbz,
'datum' => $startTime->format('Y-m-d'),
'titel' => $title,
'studiengang_kz' => is_null($studiengang) ? 0 : $studiengang,
'beschreibung' => $beschreibung,
'insertvon' => getAuthUID(),
'uid' => $lektor,
'semester' => is_null($semester) ? null : $semester,
'verband' => is_null($verband) ? null : $verband,
'gruppe' => is_null($gruppe) ? null : $gruppe,
'gruppe_kurzbz' => is_null($spezialgruppe) ? null : $spezialgruppe,
);
foreach ($stunden as $stunde)
{
$insert['stunde'] = $stunde;
$check_insert = $this->_ci->ReservierungModel->insert($insert);
if (isError($check_insert))
return $check_insert;
}
}
}
else
{
foreach ($stunden as $stunde)
{
$check_insert = $this->_ci->ReservierungModel->insert(array(
'ort_kurzbz' => $ort_kurzbz,
'uid' => getAuthUID(),
'stunde' => $stunde,
'datum' => $startTime->format('Y-m-d'),
'titel' => $title,
'studiengang_kz' => is_null($studiengang) ? 0 : $studiengang,
'beschreibung' => $beschreibung,
'insertvon' => getAuthUID()
));
if (isError($check_insert))
return $check_insert;
}
}
return success("Erfolgreich");
}
public function deleteReservation($reservierung_id)
{
$this->_ci =& get_instance();
$this->_ci->load->model('ressource/Reservierung_model', 'ReservierungModel');
$this->_ci->load->model('ressource/Stunde_model', 'StundeModel');
$this->_ci->load->library('PermissionLib');
$this->_ci->ReservierungModel->db->where_in('reservierung_id', $reservierung_id);
$reservation = $this->_ci->ReservierungModel->load();
if (isError($reservation))
return $reservation;
if (!hasData($reservation))
return error("Reservierungen nicht gefunden");
$reservations = getData($reservation);
$today = new DateTime();
foreach ($reservations as $reservierung)
{
if ($today->format('Y-m-d') > $reservierung->datum)
return error("Vergangene Reservierungen können nicht gelöscht werden");
if (($this->_ci->permissionlib->isBerechtigt('lehre/reservierung:begrenzt')) && ($reservierung->insertvon == getAuthUID() || $reservierung->uid === getAuthUID()))
{
$delete_result = $this->_ci->ReservierungModel->delete($reservierung->reservierung_id);
if (isError($delete_result))
return $delete_result;
}
}
return success("Erfolgreich");
}
public function getReservableMap($ort_kurzbz, $start_date, $end_date)
{
$this->_ci =& get_instance();
$this->_ci->load->model('ressource/Ort_model', 'OrtModel');
$this->_ci->load->library('PermissionLib');
$berechtigt_begrenzt = $this->_ci->permissionlib->isBerechtigt('lehre/reservierung:begrenzt', 'suid');
$berechtigt_erweitert = $this->_ci->permissionlib->isBerechtigt('lehre/reservierung', 'suid');
$ort_data = $this->_ci->OrtModel->load($ort_kurzbz);
if (isError($ort_data) || !hasData($ort_data))
return [];
$ort_data = getData($ort_data)[0];
if (!$ort_data->reservieren)
return [];
if (!$berechtigt_begrenzt && !$berechtigt_erweitert)
return [];
$start_ts = is_numeric($start_date) ? (int)$start_date : strtotime($start_date);
$end_ts = is_numeric($end_date) ? (int)$end_date : strtotime($end_date);
if (!$start_ts || !$end_ts)
return [];
if ($end_ts < $start_ts)
{
$tmp = $start_ts;
$start_ts = $end_ts;
$end_ts = $tmp;
}
$now = time();
$tage_min = defined('RES_TAGE_LEKTOR_MIN') ? (int)RES_TAGE_LEKTOR_MIN : 0;
$tage_bis = defined('RES_TAGE_LEKTOR_BIS') ? (int)RES_TAGE_LEKTOR_BIS : 0;
$datum_res_lektor_start = $this->jump_day($now, $tage_min - 1);
$datum_res_lektor_ende = $this->jump_day($now, $tage_bis);
$start_ymd_allowed = date('Y-m-d', $datum_res_lektor_start);
$end_ymd_allowed = date('Y-m-d', $datum_res_lektor_ende);
$result = [];
$current = strtotime(date('Y-m-d', $start_ts) . ' 00:00:00');
$end_day = strtotime(date('Y-m-d', $end_ts) . ' 00:00:00');
while ($current <= $end_day)
{
$ymd = date('Y-m-d', $current);
if ((int)date('w', $current) === 0)
{
$result[$ymd] = false;
$current = $this->jump_day($current, 1);
continue;
}
$result[$ymd] = ($ymd >= $start_ymd_allowed && $ymd <= $end_ymd_allowed) ? true : false;
$current = $this->jump_day($current, 1);
}
return success($result);
}
private function jump_day($timestamp, $days)
{
$days = (int)$days;
$prefix = ($days >= 0 ? '+' : '');
return strtotime($prefix . $days . ' days', $timestamp);
}
// start of the private functions ########################################################################################################
// function used to sort an array of studiensemester strings
-392
View File
@@ -1,392 +0,0 @@
<?php
/**
* FH-Complete
*
* @package FHC-Helper
* @author FHC-Team
* @copyright Copyright (c) 2026 fhcomplete.net
* @license GPLv3
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
use \DateTime as DateTime;
use \stdClass as stdClass;
class TagLib
{
const BATCHUSER = 'sftest';
/**
* Object initialization
*/
public function __construct()
{
$this->_ci =& get_instance();
// Configs
$this->_ci->load->config('stv');
// Models
$this->_ci->load->model('person/Notiz_model', 'NotizModel');
$this->_ci->load->model('system/Notiztyp_model', 'NotiztypModel');
$this->_ci->load->model('person/Notizzuordnung_model', 'NotizzuordnungModel');
$this->_ci->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
$this->_ci->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
// Libraries
$this->_ci->load->library('PermissionLib');
$this->_ci->load->library('PrestudentLib');
}
public function updateAutomatedTags($paramsTag)
{
// ---------------------------------
// check params
// ---------------------------------
$required = ['kurzbz', 'data', 'typeId'];
foreach ($required as $key) {
if (!isset($paramsTag[$key])) {
return error('Missing Parameter: ' . $key);
}
}
$studiensemester_kurzbz = (isset ($paramsTag['studiensemester_kurzbz']) ? $paramsTag['studiensemester_kurzbz'] : null);
$tag = $paramsTag['kurzbz'];
$inputData = $paramsTag['data'];
$typeId = $paramsTag['typeId'];
// ---------------------------------
// prepare input
// ---------------------------------
$zeitraum = [];
$arrayIds = [];
foreach ($inputData as $item) {
$id = $item['id'];
$arrayIds[] = $id;
$zeitraum[$id] = [
'von' => $item['von'] ?? null,
'bis' => $item['bis'] ?? null
];
}
$arrayIds = array_unique($arrayIds);
$result = $this->_ci->StudiensemesterModel->load($studiensemester_kurzbz);
if (isError($result)) {
return $result;
}
$data = $result->retval[0] ?? null;
$von = $data->start ?? null;
$bis = $data->ende ?? null;
// ---------------------------------
// load existing tags
// ---------------------------------
$allTags = [];
$resultAllTags = $this->_ci->NotizModel->getAllTags($tag, $von, $bis);
if (isError($resultAllTags)) {
return $resultAllTags;
}
$allTagsData = getData($resultAllTags);
if (!empty($allTagsData)) {
foreach ($allTagsData as $item) {
$allTags[$item->$typeId] = $item->notiz_id;
}
}
// ---------------------------------
// map the data
// ---------------------------------
$toRecycle = [];
$toAdd = [];
$toDelete = [];
foreach ($arrayIds as $id) {
if (isset($allTags[$id])) {
$toRecycle[$id] = $allTags[$id];
} else {
$toAdd[] = $id;
}
}
foreach ($allTags as $id => $notizId) {
if (!in_array($id, $arrayIds)) {
$toDelete[$id] = $notizId;
}
}
// ---------------------------------
// recycle (update existing)
// ---------------------------------
$countRecycled = 0;
$retagged = [];
foreach ($toRecycle as $id => $notizId)
{
$this->_updateTag($notizId, $zeitraum[$id]['von'], $zeitraum[$id]['bis']);
$countRecycled++;
$retagged[] = $id;
}
// ---------------------------------
// ADD
// ---------------------------------
$countAdded = 0;
$tagged = [];
foreach ($toAdd as $id)
{
$this->_insertTag($typeId, $id, $tag, $zeitraum[$id]['von'], $zeitraum[$id]['bis']);
$countAdded++;
$tagged[] = $id;
}
// ---------------------------------
// delete
// ---------------------------------
$countDeleted = 0;
$deleted = [];
foreach ($toDelete as $id => $notizId)
{
$result = $this->_deleteTag($notizId);
if (isError($result)) {
return $result;
}
$countDeleted++;
$deleted[] = $id;
}
// ---------------------------------
// return
// ---------------------------------
return success([
'input' => [
'tag' => $tag,
'arrayIds' => $arrayIds
],
'summary' => [
'recycled' => $countRecycled,
'added' => $countAdded,
'deleted' => $countDeleted
],
'details' => [
'existingTags' => $allTags,
'toAdd' => $toAdd,
'toRecycle' => $toRecycle,
'toDelete' => $toDelete
],
'results' => [
'retaggedIds' => $retagged,
'newTags' => $tagged,
'deletedTagsIds' => $deleted
]
]);
}
public function updateAutomatedTagsForTypeId(array $params)
{
$return = null;
$notiz_id = null;
$von = $params['von'];
$bis = $params['bis'];
$tag = $params['kurzbz'];
$id = $params['id'];
$typeId = $params['typeId'];
$this->_ci->NotizModel->addSelect('nz.notiz_id');
$this->_ci->NotizModel->addSelect($typeId);
$this->_ci->NotizModel->addJoin('public.tbl_notizzuordnung nz', 'notiz_id');
$resultAllTags = $this->_ci->NotizModel->loadWhere([
'typ' => $tag,
$typeId => $id
]);
if(hasData($resultAllTags))
{
$notiz_id = $resultAllTags->retval[0]->notiz_id;
}
//RECYCLE
if ($notiz_id !== null)
{
$resultUpdateNotiz = $this->_updateTag($notiz_id, $von, $bis);
$return = ['recycled' => $resultUpdateNotiz];
}
else
//ADD
{
$resultInsertNotiz = $this->_insertTag($typeId, $id, $tag, $von, $bis);
$return = ['added' => $resultInsertNotiz];
}
return success($return);
}
/*
* main function for rebuild Tags for typeId
* */
public function rebuildTagsForTypeId($typeId, $id, $studiensemester_kurzbz)
{
$automatedTagsRes = $this->_ci->NotiztypModel->loadWhere(array('automatisiert' => true, 'taglib IS NOT NULL' => null));
$automatedTags = hasData($automatedTagsRes) ? getData($automatedTagsRes) : [];
$result = $this->_ci->StudiensemesterModel->load($studiensemester_kurzbz);
if (isError($result))
return error('Error occurred during retrieving studiensemester');
if (empty($result->retval) || !isset($result->retval[0])) {
return error('No studiensemester found');
}
$startSem = $result->retval[0]->start ?? null;
$endeSem = $result->retval[0]->ende ?? null;
$return = [];
foreach ($automatedTags as $autoTag)
{
// getPath: must not be lost
$filePath = APPPATH . 'libraries/' . $autoTag->taglib . '.php'; // APPPATH = application/
if (file_exists($filePath)) {
require_once($filePath);
} else {
echo "File not found: " . $filePath;
continue;
}
$className = basename($autoTag->taglib);
$kurz_bz = $autoTag->typ_kurzbz;
$obj = new $className();
$criteriaIsSet = $obj->isCriteriaSetFor([
'typeId' => $typeId,
'id' => $id,
'studiensemester_kurzbz' => $studiensemester_kurzbz
]);
if (hasData($criteriaIsSet))
{
$von = isset($criteriaIsSet->retval[0]->von) ? $criteriaIsSet->retval[0]->von : '';
$bis = isset($criteriaIsSet->retval[0]->bis) ? $criteriaIsSet->retval[0]->bis : '';
$params = [
'von' => $von,
'bis' => $bis,
'kurzbz' => $autoTag->typ_kurzbz,
'typeId' => $typeId,
'id' => $id,
];
$result = $this->updateAutomatedTagsForTypeId($params);
if (isError($result))
return error('Error occurred during updateAutomatedTags' . $kurz_bz);
$return[$kurz_bz] = $result;
}
else
{
//CHECK FOR DELETE
$params = [
'von' => $startSem,
'bis' => $endeSem,
'kurzbz' => $autoTag->typ_kurzbz,
'typeId' => $typeId,
'id' => $id,
];
$result = $this->_ci->NotizModel->checkIfExistingTag($kurz_bz, $typeId, $id, $startSem, $endeSem);
if (hasData($result))
{
$notizId = $result->retval[0]->notiz_id;
$this->_deleteTag($notizId);
$return[$kurz_bz] = ['deleted' => $notizId];
}
}
}
return success($return);
}
private function _insertTag($typeId, $id, $tag, $von, $bis)
{
$resultInsert = $this->_ci->NotizModel->insert([
'titel' => 'TAG',
'text' => 'AUTOMATED TAG',
'verfasser_uid' => self::BATCHUSER,
'erledigt' => false,
'insertamum' => date('Y-m-d H:i:s'),
'insertvon' => 'BatchJobTagAdd',
'typ' => $tag,
'start' => $von,
'ende' => $bis
]);
if (isError($resultInsert)) {
return error('Error inserting tag for ' . $typeId . ': ' . $id);
}
$notizId = $resultInsert->retval;
$resultZuordnung = $this->_ci->NotizzuordnungModel->insert([
'notiz_id' => $notizId,
$typeId => $id
]);
if (isError($resultZuordnung)) {
return error('Error inserting relation for ' . $typeId . ': ' . $id);
}
return $notizId;
}
private function _updateTag($notiz_id, $von, $bis)
{
$resultUpdateNotiz = $this->_ci->NotizModel->update(
[
'notiz_id' => $notiz_id
],
array(
'updateamum' => date('Y-m-d H:i:s'),
'updatevon' => 'BatchJobTagUpdate',
'start' => $von,
'ende' => $bis
));
if (isError($resultUpdateNotiz))
return error ('Error occurred during Update ' . $notiz_id);
return $notiz_id;
}
private function _deleteTag($notiz_id)
{
$result = $this->_ci->NotizzuordnungModel->delete([
'notiz_id' => $notiz_id
]);
if (isError($result)) {
return error('Error occurred during delete Notizzuordnung ' . $notiz_id);
}
$result = $this->_ci->NotizModel->delete([
'notiz_id' => $notiz_id
]);
if (isError($result)) {
return error('Error occurred during delete Notiz ' . $notiz_id);
}
return success([
'deleted' => $notiz_id
]);
}
}
@@ -37,9 +37,7 @@ class DashboardLib
public function getDashboardByKurzbz($dashboard_kurzbz)
{
$result = $this->_ci->DashboardModel->loadWhere([
'dashboard_kurzbz' => $dashboard_kurzbz
]);
$result = $this->_ci->DashboardModel->getDashboardByKurzbz($dashboard_kurzbz);
if (hasData($result))
{
@@ -49,21 +47,17 @@ class DashboardLib
return null;
}
public function getMergedUserConfig($dashboard_id, $uid)
public function getMergedConfig($dashboard_id, $uid)
{
$defaultconfig = $this->getUserBaseConfig($dashboard_id);
$userconfig = $this->getUserOverrideConfig($dashboard_id, $uid);
$defaultconfig = $this->getDefaultConfig($dashboard_id);
$userconfig = $this->getUserConfig($dashboard_id, $uid);
$sourceconfig = array_map(function ($value) {
return ['source' => $value['source']];
}, $defaultconfig);
$mergedconfig = array_replace_recursive($defaultconfig, $userconfig, $sourceconfig);
$mergedconfig = array_replace_recursive($defaultconfig, $userconfig);
return $mergedconfig;
}
protected function getUserBaseConfig($dashboard_id)
public function getDefaultConfig($dashboard_id)
{
$funktion_kurzbzs = [];
$rights = $this->_ci->permissionlib->getAccessRights();
@@ -93,11 +87,7 @@ class DashboardLib
$preset = json_decode($presetobj->preset, true);
if (null !== $preset)
{
$preset = array_map(function ($value) use ($presetobj) {
$value['source'] = $presetobj->funktion_kurzbz ?: self::SECTION_IF_FUNKTION_KURZBZ_IS_NULL;
return $value;
}, $preset);
$defaultconfig = array_merge_recursive($defaultconfig, $preset);
$defaultconfig = array_replace_recursive($defaultconfig, $preset);
}
}
}
@@ -105,7 +95,7 @@ class DashboardLib
return $defaultconfig;
}
protected function getUserOverrideConfig($dashboard_id, $uid)
public function getUserConfig($dashboard_id, $uid)
{
$res_userconfig = $this->_ci->DashboardOverrideModel->getOverride($dashboard_id, $uid);
@@ -134,7 +124,7 @@ class DashboardLib
$emptyoverride = new stdClass();
$emptyoverride->dashboard_id = $dashboard->dashboard_id;
$emptyoverride->uid = $uid;
$emptyoverride->override = '[]';
$emptyoverride->override = '{"' . self::USEROVERRIDE_SECTION . '": {"widgets":{}}, "custom": { "widgets" : {}}}';
return $emptyoverride;
}
@@ -153,7 +143,8 @@ class DashboardLib
$emptypreset = new stdClass();
$emptypreset->dashboard_id = $dashboard->dashboard_id;
$emptypreset->funktion_kurzbz = $funktion_kurzbz;
$emptypreset->preset = '[]';
$section = ($funktion_kurzbz !== null) ? $funktion_kurzbz : self::SECTION_IF_FUNKTION_KURZBZ_IS_NULL;
$emptypreset->preset = '{"' . $section . '": { "widgets" : {}},"custom": { "widgets" : {}}}';
return $emptypreset;
}
@@ -218,4 +209,44 @@ class DashboardLib
return $result;
}
public function addWidgetsToWidgets(&$widgets, $dashboard_kurzbz, $section, $addwigets)
{
foreach ($addwigets as $widget)
{
if(!isset($widget['widgetid']))
{
$widget['widgetid'] = $this->generateWidgetId($dashboard_kurzbz);
}
$this->addWidgetToWidgets($widgets, $section, $widget, $widget['widgetid']);
}
}
public function addWidgetToWidgets(&$widgets, $section, $widget, $widgetid)
{
$section = ($section !== null) ? $section : self::SECTION_IF_FUNKTION_KURZBZ_IS_NULL;
if (!isset($widgets[$section]) || !isset($widgets[$section]["widgets"]) || !is_array($widgets[$section]))
{
$widgets[$section] = array();
$widgets[$section]["widgets"] = array();
}
$widgets[$section]["widgets"][$widgetid] = $widget;
}
public function removeWidgetFromWidgets(&$widgets, $section, $widgetid)
{
$section = ($section !== null) ? $section : self::SECTION_IF_FUNKTION_KURZBZ_IS_NULL;
if (isset($widgets[$section]) && isset($widgets[$section]["widgets"][$widgetid]))
{
unset($widgets[$section]["widgets"][$widgetid]);
if(empty($widgets[$section]["widgets"]) && $section !== self::USEROVERRIDE_SECTION) {
unset($widgets[$section]);
}
return true;
}
else {
return false;
}
}
}
@@ -1,81 +0,0 @@
<?php
/**
* Description of dd_auto
*
* @author ma0068
*/
class CoreDoubleDegreeTagLib
{
protected $ci;
public function __construct()
{
$this->ci = get_instance();
$this->ci->load->model('codex/Mobilitaet_model', 'MobilitaetModel');
}
public function getZuordnungIds(array $params)
{
if(!isset($params['studiensemester_kurzbz']))
{
return (object) array(
'idArray' => []
);
}
$semester = $params['studiensemester_kurzbz'];
$this->ci->MobilitaetModel->addJoin('bis.tbl_gsprogramm', 'gsprogramm_id');
$this->ci->MobilitaetModel->addJoin('public.tbl_studiensemester', 'studiensemester_kurzbz');
$result = $this->ci->MobilitaetModel-> loadWhere(array(
'gsprogrammtyp_kurzbz' => 'Double',
'studiensemester_kurzbz' => $semester
));
$data = $result->retval;
$doubledegree_data = array_map(function($item) {
return [
'id' => $item->prestudent_id,
'von' => $item->start,
'bis' => $item->ende
];
}, $data);
return (object) array(
'data' => $doubledegree_data,
'typeId' => 'prestudent_id'
);
}
public function isCriteriaSetFor(array $params)
{
if ( !isset($params['id'], $params['studiensemester_kurzbz'], $params['typeId']) || $params['typeId'] !== 'prestudent_id')
return false;
$semester = $params['studiensemester_kurzbz'];
$prestudent_id = $params['id'];
$this->ci->MobilitaetModel->addSelect('prestudent_id');
$this->ci->MobilitaetModel->addSelect('start as von');
$this->ci->MobilitaetModel->addSelect('ende as bis');
$this->ci->MobilitaetModel->addJoin('bis.tbl_gsprogramm', 'gsprogramm_id');
$this->ci->MobilitaetModel->addJoin('public.tbl_studiensemester', 'studiensemester_kurzbz');
$result = $this->ci->MobilitaetModel->loadWhere(array(
'gsprogrammtyp_kurzbz' => 'Double',
'studiensemester_kurzbz' => $semester,
'prestudent_id' => $prestudent_id
));
if(hasData($result))
{
//array mit prestudent_id, von und bis
return $result;
}
else
return null;
}
}
@@ -1,81 +0,0 @@
<?php
/**
* Description unruly
* Test for different typeId
*
* @author ma0068
*/
class CoreFiftyFiveTagLib
{
protected $ci;
public function __construct()
{
$this->ci = get_instance();
$this->ci->load->model('person/Person_model', 'PersonModel');
$this->ci-> load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
}
public function getZuordnungIds(array $params)
{
if(!isset($params['studiensemester_kurzbz']))
{
return (object) array(
'person_id' => []
);
}
$semester = $params['studiensemester_kurzbz'];
$result = $this->ci->StudiensemesterModel->loadWhere(array(
'studiensemester_kurzbz' => $semester
));
$data = $result->retval[0];
$semVon = $data->start;
$semBis = $data->ende;
$result = $this->ci->PersonModel->getFiftyFivers($semVon, $semBis);
$data = $result->retval;
$fiftyFiveData = array_map(function($item) {
return [
'id' => $item->person_id
];
}, $data);
return (object) array(
'data' => $fiftyFiveData,
'typeId' => 'person_id'
);
}
public function isCriteriaSetFor(array $params)
{
if ( !isset($params['id'], $params['studiensemester_kurzbz'], $params['typeId']) || $params['typeId'] !== 'person_id')
return false;
$semester = $params['studiensemester_kurzbz'];
$person_id = $params['id'];
$typeId = $params['typeId'];
$result = $this->ci->StudiensemesterModel->loadWhere(array(
'studiensemester_kurzbz' => $semester
));
$data = $result->retval[0];
$semVon = $data->start;
$semBis = $data->ende;
$result = $this->ci->PersonModel->isFiftyFive($semVon, $semBis, $person_id);
if(hasData($result))
{
return $result;
}
else
return null;
}
}
@@ -1,64 +0,0 @@
<?php
/**
* Description of jgv_auto (Jahrgangsvertretung)
*
* @author ma0068
*/
class CoreJgvTagLib
{
protected $ci;
public function __construct()
{
$this->ci = get_instance();
$this->ci->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
}
public function getZuordnungIds(array $params)
{
if(!isset($params['studiensemester_kurzbz']))
{
return (object) array(
'idArray' => []
);
}
$semester = $params['studiensemester_kurzbz'];
$result = $this->ci->BenutzerfunktionModel->getPrestudentsOfJgv($semester);
$data = $result->retval;
$jgv_data = array_map(function($item) {
return [
'id' => $item->prestudent_id,
'von' => $item->datum_von,
'bis' => $item->datum_bis
];
}, $data);
return (object) array(
'data' => $jgv_data,
'typeId' => 'prestudent_id'
);
}
public function isCriteriaSetFor(array $params)
{
if ( !isset($params['id'], $params['studiensemester_kurzbz'], $params['typeId']) || $params['typeId'] !== 'prestudent_id')
return false;
$semester = $params['studiensemester_kurzbz'];
$prestudent_id = $params['id'];
$result = $this->ci->BenutzerfunktionModel->isJgv($semester, $prestudent_id);
if(hasData($result))
{
return $result;
}
else
return null;
}
}
@@ -1,81 +0,0 @@
<?php
/**
* Description of zgv_auto
*
* @author ma0068
*/
class CoreMissingZgvTagLib
{
protected $ci;
public function __construct()
{
$this->ci = get_instance();
$this->ci->load->model('crm/Prestudent_model', 'PrestudentModel');
}
public function getZuordnungIds(array $params)
{
if(!isset($params['studiensemester_kurzbz']))
{
return (object) array(
'idArray' => []
);
}
$semester = $params['studiensemester_kurzbz'];
$this->ci->PrestudentModel->addJoin('public.tbl_prestudentstatus', 'prestudent_id');
$this->ci->PrestudentModel->addJoin('public.tbl_benutzer bn', 'person_id');
$this->ci->PrestudentModel->addJoin('public.tbl_studiengang', 'studiengang_kz');
$result = $this->ci->PrestudentModel-> loadWhere(array(
'bn.aktiv' => true, //check if necessary
'zgvdatum' => null,
'typ' => 'b',
'studiensemester_kurzbz' => $semester
));
$data = $result->retval;
$zgvmissing_data = array_map(function($item) {
return [
'id' => $item->prestudent_id,
'von' => null,
'bis' => null
];
}, $data);
return (object) array(
'typeId' => 'prestudent_id',
'data' => $zgvmissing_data
);
}
public function isCriteriaSetFor(array $params)
{
if ( !isset($params['id'], $params['studiensemester_kurzbz'], $params['typeId']) || $params['typeId'] !== 'prestudent_id')
return false;
$semester = $params['studiensemester_kurzbz'];
$prestudent_id = $params['id'];
$this->ci->PrestudentModel->addJoin('public.tbl_prestudentstatus', 'prestudent_id');
$this->ci->PrestudentModel->addJoin('public.tbl_benutzer bn', 'person_id');
$this->ci->PrestudentModel->addJoin('public.tbl_studiengang', 'studiengang_kz');
$result = $this->ci->PrestudentModel->loadWhere(array(
'bn.aktiv' => true, //check if necessary
'zgvdatum' => null,
'typ' => 'b',
'studiensemester_kurzbz' => $semester,
'prestudent_id' => $prestudent_id
));
if(hasData($result))
{
return $result;
}
else
return null;
}
}
@@ -1,63 +0,0 @@
<?php
/**
* Description of out_auto
*
* @author ma0068
*/
class CoreOutgoingTagLib
{
protected $ci;
public function __construct()
{
$this->ci = get_instance();
$this->ci->load->model('codex/Bisio_model', 'BisioModel');
}
public function getZuordnungIds(array $params)
{
if(!isset($params['studiensemester_kurzbz']))
{
return (object) array(
'idArray' => []
);
}
$semester = $params['studiensemester_kurzbz'];
$result = $this->ci->BisioModel->getOutgoingsOfSemester($semester);
$data = $result->retval;
$outgoing_data = array_map(function($item) {
return [
'id' => $item->prestudent_id,
'von' => $item->von,
'bis' => $item->bis
];
}, $data);
return (object) array(
'data' => $outgoing_data,
'typeId' => 'prestudent_id',
);
}
public function isCriteriaSetFor(array $params)
{
if ( !isset($params['id'], $params['studiensemester_kurzbz'], $params['typeId']) || $params['typeId'] !== 'prestudent_id')
return false;
$semester = $params['studiensemester_kurzbz'];
$prestudent_id = $params['id'];
$result = $this->ci->BisioModel->isPrestudentOutgoing($semester, $prestudent_id);
if (hasData($result)) {
return $result;
}
else
return null;
}
}
@@ -1,76 +0,0 @@
<?php
/**
* Description of prewh_auto
*
* @author bambi
*/
class CorePrewiederholerTagLib
{
protected $ci;
public function __construct()
{
$this->ci = get_instance();
$this->ci->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
}
public function getZuordnungIds(array $params)
{
if(!isset($params['studiensemester_kurzbz']))
{
return (object) array(
'idArray' => []
);
}
$semester = $params['studiensemester_kurzbz'];
$this->ci->PrestudentstatusModel->addJoin('public.tbl_studiensemester', 'studiensemester_kurzbz');
$result = $this->ci->PrestudentstatusModel-> loadWhere(array(
'statusgrund_id' => 15,
'studiensemester_kurzbz' => $semester
));
$data = $result->retval;
$prewiederholer_data = array_map(function($item) {
return [
'id' => $item->prestudent_id,
'von' => $item->start,
'bis' => $item->ende
];
}, $data);
return (object) array(
'data' => $prewiederholer_data,
'typeId' => 'prestudent_id',
);
}
public function isCriteriaSetFor(array $params)
{
if ( !isset($params['id'], $params['studiensemester_kurzbz'], $params['typeId']) || $params['typeId'] !== 'prestudent_id')
return false;
$semester = $params['studiensemester_kurzbz'];
$prestudent_id = $params['id'];
$this->ci->PrestudentstatusModel->addSelect('prestudent_id');
$this->ci->PrestudentstatusModel->addSelect('start as von');
$this->ci->PrestudentstatusModel->addSelect('ende as bis');
$this->ci->PrestudentstatusModel->addJoin('public.tbl_studiensemester', 'studiensemester_kurzbz');
$result = $this->ci->PrestudentstatusModel->loadWhere(array(
'statusgrund_id' => 15,
'studiensemester_kurzbz' => $semester,
'prestudent_id' => $prestudent_id
));
if(hasData($result))
{
return $result;
}
else
return null;
}
}
@@ -1,79 +0,0 @@
<?php
/**
* Description of dd_auto
*
* @author ma0068
*/
class CoreStbErhoehtTagLib
{
protected $ci;
public function __construct()
{
$this->ci = get_instance();
$this->ci->load->model('crm/Konto_model', 'KontoModel');
}
public function getZuordnungIds(array $params)
{
if(!isset($params['studiensemester_kurzbz']))
{
return (object) array(
'idArray' => []
);
}
$semester = $params['studiensemester_kurzbz'];
$this->ci->KontoModel->addJoin('public.tbl_prestudent', 'person_id');
$this->ci->KontoModel->addJoin('public.tbl_studiensemester', 'studiensemester_kurzbz');
$result = $this->ci->KontoModel-> loadWhere(array(
'buchungstyp_kurzbz' => 'StudiengebuehrErhoeht',
'studiensemester_kurzbz' => $semester
));
$data = $result->retval;
$konto_data = array_map(function($item) {
return [
'id' => $item->prestudent_id,
'von' => $item->start,
'bis' => $item->ende
];
}, $data);
return (object) array(
'data' => $konto_data,
'typeId' => 'prestudent_id'
);
}
public function isCriteriaSetFor(array $params)
{
if ( !isset($params['id'], $params['studiensemester_kurzbz'], $params['typeId']) || $params['typeId'] !== 'prestudent_id')
return false;
$semester = $params['studiensemester_kurzbz'];
$prestudent_id = $params['id'];
$this->ci->KontoModel->addSelect('prestudent_id');
$this->ci->KontoModel->addSelect('start as von');
$this->ci->KontoModel->addSelect('ende as bis');
$this->ci->KontoModel->addJoin('public.tbl_prestudent', 'person_id');
$this->ci->KontoModel->addJoin('public.tbl_studiensemester', 'studiensemester_kurzbz');
$result = $this->ci->KontoModel-> loadWhere(array(
'buchungstyp_kurzbz' => 'StudiengebuehrErhoeht',
'studiensemester_kurzbz' => $semester,
'prestudent_id' => $prestudent_id
));
if(hasData($result))
{
return $result;
}
else
return null;
}
}
@@ -1,76 +0,0 @@
<?php
/**
* Description of wiedereinstieg_auto
*
* @author ma0068
*/
class CoreUnterbrecherTagLib
{
protected $ci;
public function __construct()
{
$this->ci = get_instance();
$this->ci->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
}
public function getZuordnungIds(array $params)
{
if(!isset($params['studiensemester_kurzbz']))
{
return (object) array(
'idArray' => []
);
}
$semester = $params['studiensemester_kurzbz'];
$this->ci->PrestudentstatusModel->addJoin('public.tbl_studiensemester', 'studiensemester_kurzbz');
$result = $this->ci->PrestudentstatusModel-> loadWhere(array(
'status_kurzbz' => 'Unterbrecher',
'studiensemester_kurzbz' => $semester
));
$data = $result->retval;
$unterbrecher_data = array_map(function($item) {
return [
'id' => $item->prestudent_id,
'von' => $item->start,
'bis' => $item->ende
];
}, $data);
return (object) array(
'data' => $unterbrecher_data,
'typeId' => 'prestudent_id'
);
}
public function isCriteriaSetFor(array $params)
{
if ( !isset($params['id'], $params['studiensemester_kurzbz'], $params['typeId']) || $params['typeId'] !== 'prestudent_id')
return false;
$semester = $params['studiensemester_kurzbz'];
$prestudent_id = $params['id'];
$this->ci->PrestudentstatusModel->addSelect('prestudent_id');
$this->ci->PrestudentstatusModel->addSelect('start as von');
$this->ci->PrestudentstatusModel->addSelect('ende as bis');
$this->ci->PrestudentstatusModel->addJoin('public.tbl_studiensemester', 'studiensemester_kurzbz');
$result = $this->ci->PrestudentstatusModel-> loadWhere(array(
'status_kurzbz' => 'Unterbrecher',
'studiensemester_kurzbz' => $semester,
'prestudent_id' => $prestudent_id
));
if(hasData($result))
{
return $result;
}
else
return null;
}
}
@@ -1,76 +0,0 @@
<?php
/**
* Description of wh_auto
*
* @author bambi
*/
class CoreWiederholerTagLib
{
protected $ci;
public function __construct()
{
$this->ci = get_instance();
$this->ci->load->model('crm/Prestudentstatus_model', 'PrestudentstatusModel');
}
public function getZuordnungIds(array $params)
{
if(!isset($params['studiensemester_kurzbz']))
{
return (object) array(
'idArray' => []
);
}
$semester = $params['studiensemester_kurzbz'];
$this->ci->PrestudentstatusModel->addJoin('public.tbl_studiensemester', 'studiensemester_kurzbz');
$result = $this->ci->PrestudentstatusModel-> loadWhere(array(
'statusgrund_id' => 16,
'studiensemester_kurzbz' => $semester
));
$data = $result->retval;
$wiederholer_data = array_map(function($item) {
return [
'id' => $item->prestudent_id,
'von' => $item->start,
'bis' => $item->ende
];
}, $data);
return (object) array(
'typeId' => 'prestudent_id',
'data' => $wiederholer_data
);
}
public function isCriteriaSetFor(array $params)
{
if ( !isset($params['id'], $params['studiensemester_kurzbz'], $params['typeId']) || $params['typeId'] !== 'prestudent_id')
return false;
$semester = $params['studiensemester_kurzbz'];
$prestudent_id = $params['id'];
$this->ci->PrestudentstatusModel->addSelect('prestudent_id');
$this->ci->PrestudentstatusModel->addSelect('start as von');
$this->ci->PrestudentstatusModel->addSelect('ende as bis');
$this->ci->PrestudentstatusModel->addJoin('public.tbl_studiensemester', 'studiensemester_kurzbz');
$result = $this->ci->PrestudentstatusModel->loadWhere(array(
'statusgrund_id' => 16,
'studiensemester_kurzbz' => $semester,
'prestudent_id' => $prestudent_id,
));
if(hasData($result))
{
return $result;
}
else
return null;
}
}
@@ -40,9 +40,7 @@ abstract class AbstractBestandteil implements IValidation
if( is_bool($new_value) && ($old_value !== $new_value) ) {
$this->modifiedcolumns[$columnname] = $columnname;
} else if(is_null($old_value) xor is_null($new_value)) {
$this->modifiedcolumns[$columnname] = $columnname;
} else if($old_value != $new_value) {
} else if($old_value != $new_value) {
$this->modifiedcolumns[$columnname] = $columnname;
}
}
@@ -137,25 +137,19 @@ EOTXT;
return parent::__toString() . $txt;
}
public function validate()
/* public function validate()
{
$value = $this->vordienstzeit;
if ($value === null || $value === '') {
$result = null; // allow null value
} else {
$result = filter_var($value, FILTER_VALIDATE_INT, [
'options' => [
'min_range' => 0,
'max_range' => 100
]
]);
if ($result === false) {
$this->validationerrors[] = 'Vordienstjahre muss eine ganze Zahl (0 bis 100) enthalten oder leer sein.';
}
if( !(filter_var($this->tage, FILTER_VALIDATE_INT,
array(
'options' => array(
'min_range' => 1,
'max_range' => 50
)
)
)) ) {
$this->validationerrors[] = 'Urlaubsanspruch muss eine Tagesanzahl im Bereich 1 bis 50 sein.';
}
return parent::validate();
}
} */
}
-52
View File
@@ -44,56 +44,4 @@ class Bisio_model extends DB_Model
else
return success("Bisio not found");
}
/**
* Gets outgoing students of certain Semester
* @param String studiensemester_kurzbz
* @return array of prestudent_ids
*/
public function getOutgoingsOfSemester($studiensemester_kurzbz)
{
$query = "
SELECT DISTINCT ps.prestudent_id, tbl_bisio.von, tbl_bisio.bis
FROM bis.tbl_bisio
JOIN public.tbl_student USING (student_uid)
JOIN public.tbl_prestudent ps USING (prestudent_id)
JOIN public.tbl_prestudentstatus pss ON (ps.prestudent_id = pss.prestudent_id)
JOIN public.tbl_studiensemester ss ON (pss.studiensemester_kurzbz = ss.studiensemester_kurzbz)
WHERE ss.studiensemester_kurzbz = ?
AND (
tbl_bisio.von <= ss.ende
AND (
tbl_bisio.bis >= ss.start
OR tbl_bisio.bis IS NULL
)
)
";
return $this->execQuery($query, array($studiensemester_kurzbz));
}
public function isPrestudentOutgoing($studiensemester_kurzbz, $prestudent_id)
{
$query = "
SELECT
ps.prestudent_id, tbl_bisio.von, tbl_bisio.bis
FROM bis.tbl_bisio
JOIN public.tbl_student USING (student_uid)
JOIN public.tbl_prestudent ps USING (prestudent_id)
JOIN public.tbl_prestudentstatus pss ON (ps.prestudent_id = pss.prestudent_id)
JOIN public.tbl_studiensemester ss ON (pss.studiensemester_kurzbz = ss.studiensemester_kurzbz)
WHERE ss.studiensemester_kurzbz = ?
--AND pss.status_kurzbz = 'Student'
AND (
tbl_bisio.von <= ss.ende
AND (
tbl_bisio.bis >= ss.start
OR tbl_bisio.bis IS NULL
)
)
AND ps.prestudent_id = ?
";
return $this->execQuery($query, array($studiensemester_kurzbz, $prestudent_id));
}
}
@@ -11,73 +11,4 @@ class Mobilitaet_model extends DB_Model
$this->dbTable = 'bis.tbl_mobilitaet';
$this->pk = 'mobilitaet_id';
}
public function getMobilityZusatzForUids($uids) {
$qry = "SELECT distinct on(nachname, vorname, public.tbl_benutzer.person_id) uid,
tbl_mitarbeiter.mitarbeiter_uid,
tbl_note.lkt_ueberschreibbar, tbl_note.anmerkung,
tbl_mobilitaet.mobilitaetstyp_kurzbz,
(CASE WHEN bis.tbl_mobilitaet.studiensemester_kurzbz = vw_student_lehrveranstaltung.studiensemester_kurzbz THEN 1 ELSE 0 END) as doubledegree,
public.tbl_prestudent.gsstudientyp_kurzbz as ddtype,
(SELECT status_kurzbz FROM public.tbl_prestudentstatus
WHERE prestudent_id=tbl_student.prestudent_id
ORDER BY datum DESC, insertamum DESC, ext_id DESC LIMIT 1) as studienstatus
FROM
campus.vw_student_lehrveranstaltung
JOIN public.tbl_benutzer USING(uid)
JOIN public.tbl_person USING(person_id)
LEFT JOIN public.tbl_student ON(uid=student_uid)
LEFT JOIN public.tbl_mitarbeiter ON(uid=mitarbeiter_uid)
LEFT JOIN public.tbl_studentlehrverband USING(student_uid,studiensemester_kurzbz)
LEFT JOIN lehre.tbl_zeugnisnote on(vw_student_lehrveranstaltung.lehrveranstaltung_id=tbl_zeugnisnote.lehrveranstaltung_id
AND tbl_zeugnisnote.student_uid=tbl_student.student_uid
AND tbl_zeugnisnote.studiensemester_kurzbz=tbl_studentlehrverband.studiensemester_kurzbz)
LEFT JOIN lehre.tbl_note USING (note)
LEFT JOIN bis.tbl_bisio ON(uid=tbl_bisio.student_uid)
LEFT JOIN public.tbl_studiengang ON(tbl_student.studiengang_kz=tbl_studiengang.studiengang_kz)
LEFT JOIN bis.tbl_mobilitaet USING(prestudent_id)
LEFT JOIN public.tbl_prestudent USING(prestudent_id)
WHERE uid IN ?";
return $this->execReadOnlyQuery($qry, [$uids]);
}
public function formatZusatz($entry, $erhalter_kz) {
$zusatz = '';
if (isset($entry->studienstatus) && $entry->studienstatus === 'Incoming') {
$zusatz = '(i)';
}
if (isset($entry->lkt_ueberschreibbar) && $entry->lkt_ueberschreibbar === false) {
$zusatz .= ' (' . ($entry->anmerkung ?? '') . ')';
}
if (isset($entry->mitarbeiter_uid) && $entry->mitarbeiter_uid !== null) {
$zusatz .= ' (ma)';
}
if (isset($entry->stg_kz_student) && $entry->stg_kz_student == $erhalter_kz) {
$zusatz .= ' (a.o.)';
}
if (
isset($entry->mobilitaetstyp_kurzbz) && $entry->mobilitaetstyp_kurzbz &&
isset($entry->doubledegree) && $entry->doubledegree === 1
) {
$zusatz .= ' (d.d.';
$ddtype = $entry->ddtype ?? null;
if ($ddtype == 'Intern') {
$zusatz .= 'i.)';
} elseif ($ddtype == 'Extern') {
$zusatz .= 'o.)';
} else {
$zusatz .= ')';
}
}
return $zusatz;
}
}
+3 -3
View File
@@ -234,9 +234,9 @@ class Content_model extends DB_Model
FROM
campus.tbl_content c1
LEFT JOIN
campus.tbl_contentsprache s1 ON c1.content_id=s1.content_id AND s1.sprache=? AND sichtbar=true
campus.tbl_contentsprache s1 ON c1.content_id=s1.content_id AND s1.sprache=?
WHERE
c1.aktiv = true
sichtbar=true
) s2
LEFT JOIN
campus.tbl_contentsprache s3 USING(content_id, sprache)
@@ -277,7 +277,7 @@ class Content_model extends DB_Model
JOIN
campus.tbl_contentsprache s USING(contentsprache_id)
LEFT JOIN
campus.tbl_contentchild k ON(m.content_id=k.content_id) and c.aktiv = true
campus.tbl_contentchild k ON(m.content_id=k.content_id)
WHERE EXISTS (
SELECT 1
FROM campus.tbl_contentgruppe
+1 -56
View File
@@ -248,60 +248,5 @@ class Akte_model extends DB_Model
return success($dokumente->retval);
}
/**
* Liefert die Archivdokumente einer Person/mehrerer Personen
*
* @param integer/array $person_id
* @param boolean|null $signiert Wenn true werden nur Dokumente geliefert die digital signiert wurden.
* @param boolean|null $stud_selfservice Wenn true werden nur Dokumente geliefert die Studierende selbst herunterladen duerfen.
*
* @return stdClass
*/
public function getArchiv($person_id, $signiert = null, $stud_selfservice = null)
{
$this->addSelect('akte_id');
$this->addSelect('person_id');
$this->addSelect('dokument_kurzbz');
$this->addSelect('mimetype');
$this->addSelect('erstelltam');
$this->addSelect('gedruckt');
$this->addSelect('titel_intern');
$this->addSelect('anmerkung_intern');
$this->addSelect('titel');
$this->addSelect('bezeichnung');
$this->addSelect('updateamum');
$this->addSelect('insertamum');
$this->addSelect('updatevon');
$this->addSelect('insertvon');
$this->addSelect('uid');
$this->addSelect('dms_id');
$this->addSelect('anmerkung');
$this->addSelect('nachgereicht');
$this->addSelect('CASE WHEN inhalt is not null THEN true ELSE false END as inhalt_vorhanden', false);
$this->addSelect('nachgereicht_am');
$this->addSelect('ausstellungsnation');
$this->addSelect('formal_geprueft_amum');
$this->addSelect('archiv');
$this->addSelect('signiert');
$this->addSelect('stud_selfservice');
$this->addSelect('akzeptiertamum');
if ($signiert !== null)
$this->db->where('signiert', (boolean)$signiert);
if ($stud_selfservice !== null)
$this->db->where('stud_selfservice', (boolean)$stud_selfservice);
if (is_array($person_id))
$this->db->where_in('person_id', $person_id);
else
$this->db->where('person_id', $person_id);
$this->addOrder('erstelltam', 'DESC');
$this->addOrder('akte_id', 'DESC');
return $this->loadWhere([
'archiv' => true
]);
}
}
@@ -11,4 +11,8 @@ class Bookmark_model extends DB_Model
$this->dbTable = 'dashboard.tbl_bookmark';
$this->pk = 'bookmark_id';
}
}
@@ -11,4 +11,15 @@ class Dashboard_model extends DB_Model
$this->dbTable = 'dashboard.tbl_dashboard';
$this->pk = 'dashboard_id';
}
/**
* Get Dashboard by kurzbz.
* @param string dashboard_kurzbz
* @return array
*/
public function getDashboardByKurzbz($dashboard_kurzbz)
{
return $this->loadWhere(array('dashboard_kurzbz' => $dashboard_kurzbz));
}
}
@@ -100,14 +100,12 @@ class Abschlusspruefung_model extends DB_Model
if (isError($abschlussarbeit))
return $abschlussarbeit;
if (hasData($abschlussarbeit))
{
$abschlussarbeit = getData($abschlussarbeit)[0];
$abschlusspruefungdata->projektarbeit_studiengangstyp_name = $abschlussarbeit->projekttyp_kurzbz;
$abschlusspruefungdata->abschlussarbeit_titel = $abschlussarbeit->titel;
$abschlusspruefungdata->abschlussarbeit_note = $abschlussarbeit->note;
$abschlusspruefungdata->abschlussarbeit_sprache = $abschlussarbeit->sprache_bezeichnung;
}
}
}
@@ -52,53 +52,4 @@ class LePruefung_model extends DB_Model
'student_uid' => $student_uid
]);
}
public function getPruefungenByLvStudiensemester($lv_id, $sem_kurzbz) {
$qry = "SELECT lehre.tbl_pruefung.*, tbl_lehrveranstaltung.bezeichnung as lehrveranstaltung_bezeichnung, tbl_lehrveranstaltung.lehrveranstaltung_id,
tbl_note.bezeichnung as note_bezeichnung, tbl_pruefungstyp.beschreibung as typ_beschreibung, tbl_lehreinheit.studiensemester_kurzbz as studiensemester_kurzbz
FROM lehre.tbl_pruefung, lehre.tbl_lehreinheit, lehre.tbl_lehrveranstaltung, lehre.tbl_note, lehre.tbl_pruefungstyp
WHERE lehre.tbl_pruefung.lehreinheit_id=tbl_lehreinheit.lehreinheit_id
AND tbl_lehreinheit.lehrveranstaltung_id=tbl_lehrveranstaltung.lehrveranstaltung_id
AND lehre.tbl_pruefung.note = tbl_note.note
AND lehre.tbl_pruefung.pruefungstyp_kurzbz=tbl_pruefungstyp.pruefungstyp_kurzbz
AND tbl_lehrveranstaltung.lehrveranstaltung_id = ?
AND tbl_lehreinheit.studiensemester_kurzbz = ?
ORDER BY datum DESC;";
return $this->execReadOnlyQuery($qry, array($lv_id, $sem_kurzbz));
}
public function getPruefungenByUidTypLvStudiensemester($uid, $typ = null, $lv_id = null, $sem_kurzbz = null) {
$params = [$uid];
$qry = "SELECT tbl_pruefung.*, tbl_lehrveranstaltung.bezeichnung as lehrveranstaltung_bezeichnung, tbl_lehrveranstaltung.lehrveranstaltung_id,
tbl_note.bezeichnung as note_bezeichnung, tbl_pruefungstyp.beschreibung as typ_beschreibung, tbl_lehreinheit.studiensemester_kurzbz as studiensemester_kurzbz
FROM lehre.tbl_pruefung, lehre.tbl_lehreinheit, lehre.tbl_lehrveranstaltung, lehre.tbl_note, lehre.tbl_pruefungstyp
WHERE student_uid= ?
AND tbl_pruefung.lehreinheit_id=tbl_lehreinheit.lehreinheit_id
AND tbl_lehreinheit.lehrveranstaltung_id=tbl_lehrveranstaltung.lehrveranstaltung_id
AND tbl_pruefung.note = tbl_note.note
AND tbl_pruefung.pruefungstyp_kurzbz=tbl_pruefungstyp.pruefungstyp_kurzbz";
if ($typ != null)
{
$qry .= " AND tbl_pruefungstyp.pruefungstyp_kurzbz = ?";
$params[] = $typ;
}
if ($lv_id != null)
{
$qry .= " AND tbl_lehrveranstaltung.lehrveranstaltung_id = ?";
$params[] = $lv_id;
}
if ($sem_kurzbz != null)
{
$qry .= " AND tbl_lehreinheit.studiensemester_kurzbz = ?";
$params[] = $sem_kurzbz;
}
$qry .= " ORDER BY datum DESC";
return $this->execReadOnlyQuery($qry, $params);
}
}

Some files were not shown because too many files have changed in this diff Show More