Merge branch 'master' into dbskel

This commit is contained in:
Paolo
2020-11-13 20:55:57 +01:00
172 changed files with 15744 additions and 6090 deletions
+44 -43
View File
@@ -20,31 +20,31 @@ class LehrauftragJob extends JOB_Controller
{
const BERECHTIGUNG_LEHRAUFTRAG_ERTEILEN = 'lehre/lehrauftrag_erteilen';
const BERECHTIGUNG_LEHRAUFTRAG_AKZEPTIEREN = 'lehre/lehrauftrag_akzeptieren';
const LEHRAUFTRAG_ERTEILEN_URI = 'lehre/lehrauftrag/LehrauftragErteilen';
const LEHRAUFTRAG_AKZEPTIEREN_URI = '/lehre/lehrauftrag/LehrauftragAkzeptieren';
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
// Load models
$this->load->model('accounting/Vertrag_model', 'VertragModel');
$this->load->model('accounting/Vertragvertragsstatus_model', 'VertragvertragsstatusModel');
$this->load->model('education/Lehrveranstaltung_model', 'LehrveranstaltungModel');
$this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
$this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel');
// Load libraries
$this->load->library('PermissionLib');
// Load helpers
$this->load->helper('hlp_sancho_helper');
}
/**
* This daily job sends information about all lehr-/projektauftraege ordered (and not approved) the day bofore.
* Receivers: Department-/Kompetenzfeldleiter
@@ -62,7 +62,7 @@ class LehrauftragJob extends JOB_Controller
foreach ($vertrag_arr as $vertrag)
{
$result = $this->VertragModel->getLehreinheitData($vertrag->vertrag_id, 'lehrveranstaltung_id, studiensemester_kurzbz');
if (hasData($result))
{
$obj = new StdClass();
@@ -72,7 +72,7 @@ class LehrauftragJob extends JOB_Controller
}
}
}
/**
* Build the data array to be used in the email. Data array is clustered as follows:
* Array
@@ -90,7 +90,7 @@ class LehrauftragJob extends JOB_Controller
foreach ($lehreinheit_data_arr as $lehreinheit_data)
{
$result = $this->_getLVData($lehreinheit_data->lehrveranstaltung_id);
if (hasData($result))
{
// Search if studiensemester exists in data_arr
@@ -102,12 +102,12 @@ class LehrauftragJob extends JOB_Controller
$data = array(
'studiensemester_kurzbz' => $lehreinheit_data->studiensemester_kurzbz
);
$data []= array(
'oe_kurzbz' => $result->retval[0]->oe_kurzbz,
'oe_bezeichnung' => $result->retval[0]->lv_oe_bezeichnung
);
// Add stg data to oe, start amount with 1
$data[0][] = array(
'stg_kz' => $result->retval[0]->studiengang_kz,
@@ -115,7 +115,7 @@ class LehrauftragJob extends JOB_Controller
'stg_bezeichnung' => $result->retval[0]->lv_stg_bezeichnung,
'amount' => 1
);
// Push to final data_arr
$data_arr []= $data;
}
@@ -124,7 +124,7 @@ class LehrauftragJob extends JOB_Controller
{
// Search if oe exists inside existing studiensemester of data_arr
$oe_index = array_search($result->retval[0]->oe_kurzbz, array_column($data_arr[$ss_index], 'oe_kurzbz'));
// If oe is new, add oe and stg to studiensemester
if ($oe_index === false)
{
@@ -132,7 +132,7 @@ class LehrauftragJob extends JOB_Controller
$data_arr[$ss_index][] = array(
'oe_kurzbz' => $result->retval[0]->oe_kurzbz,
'oe_bezeichnung' => $result->retval[0]->lv_oe_bezeichnung,
// Add stg data to oe, start amount with 1
array(
'stg_kz' => $result->retval[0]->studiengang_kz,
@@ -147,7 +147,7 @@ class LehrauftragJob extends JOB_Controller
{
// Search if stg exists inside existing oe of data_arr
$stg_index = array_search($result->retval[0]->studiengang_kz, array_column($data_arr[$ss_index][$oe_index], 'stg_kz'));
// If stg is new, add stg to oe, start amount with 1
if ($stg_index === false)
{
@@ -168,7 +168,7 @@ class LehrauftragJob extends JOB_Controller
}
}
}
/**
* Cluster data by uid of entitled mail receivers.
* Returning array is clustered as follows:
@@ -186,7 +186,7 @@ class LehrauftragJob extends JOB_Controller
* [amount] // amount of new ordered lehrauftraege of that stg
*/
$data_arr = $this->_clusterData_byReceiver($data_arr);
// Send email
if(!$this->_sendMail_toApprove($data_arr))
{
@@ -197,7 +197,7 @@ class LehrauftragJob extends JOB_Controller
$this->logError('Error when sending emails in job MailLehrauftragToApprove');
}
}
/**
* This daily job sends information about all lehr-/projektauftraege approved the day bofore.
* Receivers: lectors
@@ -208,7 +208,7 @@ class LehrauftragJob extends JOB_Controller
$this->VertragvertragsstatusModel->addSelect('vertrag_id, uid');
$this->VertragvertragsstatusModel->addOrder('uid');
$result = $this->VertragvertragsstatusModel->getApproved_fromDate('YESTERDAY');
/**
* Build the data array to be used in the email. Data array is clustered as follows:
* Array
@@ -228,10 +228,10 @@ class LehrauftragJob extends JOB_Controller
{
$studiensemester = $studiensemester[0]->vertragsstunden_studiensemester_kurzbz;
}
// Search if uid exists in data_arr
$uid_index = array_search($vertrag->uid, array_column($data_arr, 'uid'));
// If uid is new, add uid, studiensemester and start amount with 1
if ($uid_index === false)
{
@@ -249,7 +249,7 @@ class LehrauftragJob extends JOB_Controller
{
$data_arr[$uid_index]['studiensemester'] .= ' und '. $studiensemester;
}
// Increase amount +1
$data_arr[$uid_index]['amount']++;
}
@@ -266,11 +266,11 @@ class LehrauftragJob extends JOB_Controller
$this->logError('Error when sending emails in job MailLehrauftragToAccept');
}
}
//******************************************************************************************************************
// PRIVATE FUNCTIONS
//******************************************************************************************************************
/**
* Get data of given lehrveranstaltung.
* @param $lehrveranstaltung_id
@@ -286,7 +286,7 @@ class LehrauftragJob extends JOB_Controller
stg.typ AS "stg_typ",
stg.kurzbz AS "stg_kurzbz"
');
$this->LehrveranstaltungModel->addJoin('lehre.tbl_studienplan_lehrveranstaltung stpllv', 'lehrveranstaltung_id');
$this->LehrveranstaltungModel->addJoin('lehre.tbl_studienplan stpl', 'studienplan_id');
$this->LehrveranstaltungModel->addJoin('lehre.tbl_studienordnung sto', 'studienordnung_id');
@@ -294,10 +294,10 @@ class LehrauftragJob extends JOB_Controller
$this->LehrveranstaltungModel->addJoin('public.tbl_organisationseinheit oe', 'ON oe.oe_kurzbz = tbl_lehrveranstaltung.oe_kurzbz');
$this->LehrveranstaltungModel->addOrder('stpllv.insertamum', 'DESC');
$this->LehrveranstaltungModel->addLimit(1);
return $this->LehrveranstaltungModel->load($lehrveranstaltung_id);
}
/**
* Send Sancho eMail about ordered Lehrauftraege.
* @param $data_arr
@@ -310,12 +310,12 @@ class LehrauftragJob extends JOB_Controller
// Set mail recipients (department assistance/leader)
$to = $data['uid']. '@'. DOMAIN;
$html_table = $this->_renderData_LehrauftraegeToApprove($data);
// Prepare mail content
$content_data_arr = array(
'table' => $html_table
);
sendSanchoMail(
'LehrauftragNeueBestellungen',
$content_data_arr,
@@ -326,7 +326,7 @@ class LehrauftragJob extends JOB_Controller
);
}
}
/**
* Cluster the data array by entitled mail receiver.
* Returning array is clustered as follows:
@@ -409,7 +409,7 @@ class LehrauftragJob extends JOB_Controller
return $mail_data_arr;
}
/**
* Render the data array for the mail template returing a HTML table.
* @param $data_arr Data to be used in HTML table
@@ -425,11 +425,11 @@ class LehrauftragJob extends JOB_Controller
if (isset($studiensemester_container['studiensemester_kurzbz']))
{
$studiensemester = $studiensemester_container['studiensemester_kurzbz'];
// Link to LehrauftragErteilen
$url = site_url(self::LEHRAUFTRAG_ERTEILEN_URI).'?studiensemester='. $studiensemester;
}
// HTML table header
$html .= '
<br>
@@ -446,7 +446,7 @@ class LehrauftragJob extends JOB_Controller
</thead>
<tbody>'
;
// HTML table body
foreach ($studiensemester_container as $oe_container)
{
@@ -456,7 +456,7 @@ class LehrauftragJob extends JOB_Controller
{
$oe_bezeichnung = $oe_container['oe_bezeichnung'];
}
foreach ($oe_container as $stg_data)
{
if (is_array($stg_data)) // is_array 'trims' the outer associative keys [oe_kurzbz] and [oe_bezeichnung]
@@ -473,7 +473,7 @@ class LehrauftragJob extends JOB_Controller
}
}
}
// HTML table body end and link
$html .= '
</tbody>
@@ -484,10 +484,10 @@ class LehrauftragJob extends JOB_Controller
';
}
}
return $html;
}
/**
* Send Sancho eMail about ordered Lehrauftraege.
* @param $data_arr
@@ -499,24 +499,24 @@ class LehrauftragJob extends JOB_Controller
{
// Set mail recipient (lector)
$to = $data['uid']. '@'. DOMAIN;
// Link to LehrauftragAkzeptieren
$url = CIS_ROOT. 'cis/index.php?menu='.
CIS_ROOT. 'cis/menu.php?content_id=&content='.
CIS_ROOT. index_page(). self::LEHRAUFTRAG_AKZEPTIEREN_URI;
// Get first name
$first_name = '';
$this->load->model('person/Benutzer_model', 'BenutzerModel');
$this->BenutzerModel->addSelect('vorname');
$this->BenutzerModel->addJoin('public.tbl_person', 'person_id');
$result = $this->BenutzerModel->loadWhere(array('uid' => $data['uid']));
if (hasData($result))
{
$first_name = $result->retval[0]->vorname;
}
// Prepare mail content
$content_data_arr = array(
'vorname' => $first_name,
@@ -524,7 +524,7 @@ class LehrauftragJob extends JOB_Controller
'anzahl' => $data['amount'],
'link' => anchor($url, 'Lehraufträge Übersicht')
);
sendSanchoMail(
'LehrauftragNeueErteilte',
$content_data_arr,
@@ -532,5 +532,6 @@ class LehrauftragJob extends JOB_Controller
'Neu erteilte Lehraufträge zum Annehmen bereit'
);
}
return true;
}
}
@@ -27,11 +27,11 @@ class OneTimeMessages extends JOB_Controller
* - Status set as "Wartender"
* - The given study course type (b = bachelor, m = master)
* - The given semester (ex WS2020)
* - How long since applicant (months)
* - How long since applicant (days)
* - The given template id to be used as message subject and body (vorlage_kurzbz)
* The sender of all the messages is specified by the parameter senderId (sender person_id)
*/
public function sendMessageToApplicantsStillWaiting($senderId, $studyCourseType, $semester, $months, $messageTemplate)
public function sendMessageToApplicantsStillWaiting($senderId, $studyCourseType, $semester, $days, $messageTemplate)
{
$this->logInfo('Send message to applicants still waiting start');
@@ -47,13 +47,13 @@ class OneTimeMessages extends JOB_Controller
$dbModel = new DB_Model();
$dbPrestudents = $dbModel->execReadOnlyQuery(
'SELECT p.prestudent_id
'SELECT distinct on(person_id) p.prestudent_id
FROM public.tbl_prestudent p
JOIN public.tbl_prestudentstatus ps USING (prestudent_id)
JOIN public.tbl_studiengang s USING (studiengang_kz)
WHERE ps.status_kurzbz = \'Wartender\'
AND ps.studiensemester_kurzbz = ?
AND ps.datum <= NOW() - \''.$months.' months\'::interval
AND ps.datum <= NOW() - \''.$days.' days\'::interval
AND s.typ = ?
AND NOT EXISTS (
SELECT pp.person_id
@@ -0,0 +1,232 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*/
class Pruefungsprotokoll extends Auth_Controller
{
private $_uid; // uid of the logged user
/**
* Constructor
*/
public function __construct()
{
// Set required permissions
parent::__construct(
array(
'index' => 'lehre/pruefungsbeurteilung:r',
'Protokoll' => 'lehre/pruefungsbeurteilung:r',
'saveProtokoll' => 'lehre/pruefungsbeurteilung:rw',
)
);
// Load models
$this->load->model('education/Abschlusspruefung_model', 'AbschlusspruefungModel');
$this->load->model('education/Abschlussbeurteilung_model', 'AbschlussbeurteilungModel');
$this->load->library('PermissionLib');
$this->load->library('AuthLib');
// Load language phrases
$this->loadPhrases(
array(
'ui',
'global',
'person',
'abschlusspruefung',
'password',
'lehre'
)
);
$this->_setAuthUID(); // sets property uid
$this->setControllerId(); // sets the controller id
}
// -----------------------------------------------------------------------------------------------------------------
// Public methods
public function index()
{
$this->load->library('WidgetLib');
// Protokolle anzeigen seit heute / letzte Woche / alle
$period = $this->input->post('period');
$period = (!is_null($period)) ? $period : 'today';
$data = array('period' => $period);
$this->load->view('lehre/pruefungsprotokollUebersicht.php', $data);
}
/**
* Show Pruefungsprotokoll.
*/
public function Protokoll()
{
$abschlusspruefung_id = $this->input->get('abschlusspruefung_id');
if (!is_numeric($abschlusspruefung_id))
show_error('invalid abschlusspruefung');
$abschlusspruefung_saved = false;
$abschlusspruefung = $this->_getAbschlusspruefungBerechtigt($abschlusspruefung_id);
if (isError($abschlusspruefung))
show_error(getError($abschlusspruefung));
else
{
$abschlusspruefung = getData($abschlusspruefung);
$abschlusspruefung_saved = isset($abschlusspruefung->protokoll) && isset($abschlusspruefung->abschlussbeurteilung_kurzbz);
}
$this->AbschlussbeurteilungModel->addOrder("sort", "ASC");
$this->AbschlussbeurteilungModel->addOrder("(CASE WHEN abschlussbeurteilung_kurzbz = 'ausgezeichnet' THEN 1
WHEN abschlussbeurteilung_kurzbz = 'gut' THEN 2
WHEN abschlussbeurteilung_kurzbz = 'bestanden' THEN 3
WHEN abschlussbeurteilung_kurzbz = 'angerechnet' THEN 4
ELSE 5
END
)");
$abschlussbeurteilung = $this->AbschlussbeurteilungModel->load();
if (isError($abschlussbeurteilung))
show_error(getError($abschlussbeurteilung));
else
$abschlussbeurteilung = getData($abschlussbeurteilung);
$language = getUserLanguage();
$data = array(
'abschlusspruefung' => $abschlusspruefung,
'abschlussbeurteilung' => $abschlussbeurteilung,
'abschlusspruefung_saved' => $abschlusspruefung_saved,
'language' => $language
);
$this->load->view('lehre/pruefungsprotokoll.php', $data);
}
/**
* Save Pruefungsprotokoll (including possible Freigabe)
*/
public function saveProtokoll()
{
$abschlusspruefung_id = $this->input->post('abschlusspruefung_id');
$freigebendata = $this->input->post('freigebendata');
$protocoldata = $this->input->post('protocoldata');
if (isset($abschlusspruefung_id) && is_numeric($abschlusspruefung_id)
&& isset($freigebendata['freigeben']) && isset($protocoldata))
{
// check permission
$berechtigt = $this->_getAbschlusspruefungBerechtigt($abschlusspruefung_id);
if (isError($berechtigt))
$this->outputJsonError(getError($berechtigt));
else
{
$freigabe = $freigebendata['freigeben'] === 'true';
if ($freigabe)
{
// Verify password
if (isset($freigebendata['password']) && !isEmptyString($freigebendata['password']))
{
$password = $freigebendata['password'];
$result = $this->authlib->checkUserAuthByUsernamePassword($this->_uid, $password);
if (isError($result))
{
return $this->outputJsonError($this->p->t('password', 'wrongPassword')); // exit if password is incorrect
}
}
else
{
return $this->outputJsonError($this->p->t('password', 'passwordMissing'));
}
}
$data = $this->_prepareAbschlusspruefungDataForSave($protocoldata, $freigabe);
$result = $this->AbschlusspruefungModel->update($abschlusspruefung_id, $data);
if (hasData($result))
{
$abschlusspruefung_id = getData($result);
$updateresult = array('abschlusspruefung_id' => $abschlusspruefung_id);
if ($freigabe)
$updateresult['freigabedatum'] = date_format(date_create($data['freigabedatum']), 'd.m.Y');
$this->outputJsonSuccess($updateresult);
}
else
$this->outputJsonError('Fehler beim Speichern des Prüfungsprotokolls');
}
}
else
$this->outputJsonError($this->p->t('ui', 'ungueltigeParameter'));
}
// -----------------------------------------------------------------------------------------------------------------
// Private methods
/**
* Retrieve the UID of the logged user and checks if it is valid
*/
private function _setAuthUID()
{
$this->_uid = getAuthUID();
if (!$this->_uid) show_error('User authentification failed');
}
/**
* Retrieves an Abschlussprüfung, with permission check
* permission: admin, assistance of study programe or Vorsitz of the Prüfung
* @param $abschlusspruefung_id
* @return object success or error
*/
private function _getAbschlusspruefungBerechtigt($abschlusspruefung_id)
{
$result = error('Error when getting Abschlusspruefung');
if (isset($this->_uid))
{
$abschlusspruefung = $this->AbschlusspruefungModel->getAbschlusspruefung($abschlusspruefung_id);
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))
|| $this->_uid === $abschlusspruefung_data->uid_vorsitz)
$result = $abschlusspruefung;
else
$result = error('Permission denied');
}
}
return $result;
}
/**
* Prepares Abschlussprüfung for save in database, replaces '' with null, sets Freigabedatum
* @param $data
* @return array
*/
private function _prepareAbschlusspruefungDataForSave($data, $freigabe)
{
$nullfields = array('uhrzeit', 'endezeit', 'abschlussbeurteilung_kurzbz', 'protokoll');
foreach ($data as $idx => $item)
{
if (in_array($idx, $nullfields) & $item === '')
$data[$idx] = null;
}
if ($freigabe === true)
$data['freigabedatum'] = date('Y-m-d');
return $data;
}
}
@@ -52,7 +52,8 @@ class Lehrauftrag extends Auth_Controller
array(
'global',
'ui',
'lehre'
'lehre',
'table'
)
);
@@ -8,180 +8,196 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
*/
class LehrauftragAkzeptieren extends Auth_Controller
{
const APP = 'lehrauftrag';
const LEHRAUFTRAG_URI = 'lehre/lehrauftrag/LehrauftragAkzeptieren'; // URL prefix for this controller
const BERECHTIGUNG_LEHRAUFTRAG_AKZEPTIEREN = 'lehre/lehrauftrag_akzeptieren';
const APP = 'lehrauftrag';
const LEHRAUFTRAG_URI = 'lehre/lehrauftrag/LehrauftragAkzeptieren'; // URL prefix for this controller
const BERECHTIGUNG_LEHRAUFTRAG_AKZEPTIEREN = 'lehre/lehrauftrag_akzeptieren';
private $_uid; // uid of the logged user
private $_uid; // uid of the logged user
/**
* Constructor
*/
public function __construct()
{
// Set required permissions
parent::__construct(
array(
'index' => 'lehre/lehrauftrag_akzeptieren:r',
'acceptLehrauftrag' => 'lehre/lehrauftrag_akzeptieren:rw',
/**
* Constructor
*/
public function __construct()
{
// Set required permissions
parent::__construct(
array(
'index' => 'lehre/lehrauftrag_akzeptieren:r',
'acceptLehrauftrag' => 'lehre/lehrauftrag_akzeptieren:rw',
'checkInkludierteLehre' => 'lehre/lehrauftrag_akzeptieren:rw'
)
);
)
);
// Load models
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$this->load->model('accounting/Vertrag_model', 'VertragModel');
$this->load->model('accounting/Vertragvertragsstatus_model', 'VertragvertragsstatusModel');
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
$this->load->model('codex/Bisverwendung_model', 'BisverwendungModel');
$this->load->model('person/Benutzer_model', 'BenutzerModel');
// Load models
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$this->load->model('accounting/Vertrag_model', 'VertragModel');
$this->load->model('accounting/Vertragvertragsstatus_model', 'VertragvertragsstatusModel');
$this->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
$this->load->model('codex/Bisverwendung_model', 'BisverwendungModel');
$this->load->model('person/Benutzer_model', 'BenutzerModel');
// Load libraries
$this->load->library('WidgetLib');
$this->load->library('PermissionLib');
$this->load->library('AuthLib');
// Load libraries
$this->load->library('WidgetLib');
$this->load->library('PermissionLib');
$this->load->library('AuthLib');
// Load helpers
$this->load->helper('array');
$this->load->helper('url');
// Load helpers
$this->load->helper('array');
$this->load->helper('url');
// Load language phrases
$this->loadPhrases(
array(
'global',
'ui',
'lehre'
)
);
// Load language phrases
$this->loadPhrases(
array(
'global',
'ui',
'lehre',
'password',
'dms',
'table'
)
);
$this->_setAuthUID(); // sets property uid
$this->_setAuthUID(); // sets property uid
$this->setControllerId(); // sets the controller id
}
$this->setControllerId(); // sets the controller id
}
// -----------------------------------------------------------------------------------------------------------------
// Public methods
// -----------------------------------------------------------------------------------------------------------------
// Public methods
/**
* Main page of Lehrauftrag
*/
public function index()
{
// Set studiensemester selected for studiengang dropdown
$studiensemester_kurzbz = $this->input->get('studiensemester'); // if provided by selected studiensemester
if (is_null($studiensemester_kurzbz)) // else set next studiensemester as default value
{
$studiensemester = $this->StudiensemesterModel->getAktOrNextSemester();
if (hasData($studiensemester))
{
$studiensemester_kurzbz = $studiensemester->retval[0]->studiensemester_kurzbz;
}
elseif (isError($studiensemester))
{
show_error(getError($studiensemester));
}
}
/**
* Main page of Lehrauftrag
*/
public function index()
{
// Set studiensemester selected for studiengang dropdown
$studiensemester_kurzbz = $this->input->get('studiensemester'); // if provided by selected studiensemester
if (is_null($studiensemester_kurzbz)) // else set next studiensemester as default value
{
$studiensemester = $this->StudiensemesterModel->getAktOrNextSemester();
if (hasData($studiensemester))
{
$studiensemester_kurzbz = $studiensemester->retval[0]->studiensemester_kurzbz;
}
elseif (isError($studiensemester))
{
show_error(getError($studiensemester));
}
}
$view_data = array(
'studiensemester_selected' => $studiensemester_kurzbz
);
// Check if user is external lector
$this->MitarbeiterModel->addJoin('public.tbl_benutzer', 'uid = mitarbeiter_uid');
$result = $this->MitarbeiterModel->loadWhere(array(
'uid' => $this->_uid,
'fixangestellt' => false,
'personalnummer > ' => 0,
'lektor' => true,
'aktiv' => true
));
$is_external_lector = hasData($result) ? true : false;
$view_data = array(
'studiensemester_selected' => $studiensemester_kurzbz,
'is_external_lector' => $is_external_lector
);
$this->load->view('lehre/lehrauftrag/acceptLehrauftrag.php', $view_data);
}
$this->load->view('lehre/lehrauftrag/acceptLehrauftrag.php', $view_data);
}
/**
* Set the contract status of Lehrauftrag to 'akzeptiert'.
* Performed on ajax call.
*/
public function acceptLehrauftrag()
{
// Verify password
$password = $this->input->post('password');
if (!isEmptyString($password))
{
$result = $this->authlib->checkUserAuthByUsernamePassword($this->_uid, $password);
if (isError($result))
{
return $this->outputJsonError('Passwort ist inkorrekt'); // exit if password is incorrect
}
}
else
{
/**
* Set the contract status of Lehrauftrag to 'akzeptiert'.
* Performed on ajax call.
*/
public function acceptLehrauftrag()
{
// Verify password
$password = $this->input->post('password');
if (!isEmptyString($password))
{
$result = $this->authlib->checkUserAuthByUsernamePassword($this->_uid, $password);
if (isError($result))
{
return $this->outputJsonError('Passwort ist inkorrekt'); // exit if password is incorrect
}
}
else
{
return $this->outputJsonError('Passwort fehlt');
}
}
// Loop through lehraufträge
$lehrauftrag_arr = $this->input->post('selected_data');
// Loop through lehraufträge
$lehrauftrag_arr = $this->input->post('selected_data');
if(is_array($lehrauftrag_arr))
{
foreach($lehrauftrag_arr as $lehrauftrag)
{
$vertrag_id = (!is_null($lehrauftrag['vertrag_id'])) ? $lehrauftrag['vertrag_id'] : null;
if(is_array($lehrauftrag_arr))
{
foreach($lehrauftrag_arr as $lehrauftrag)
{
$vertrag_id = (!is_null($lehrauftrag['vertrag_id'])) ? $lehrauftrag['vertrag_id'] : null;
// Check if user is entitled to accept this Lehrauftrag
// * first retrieve person_id of the contract
$this->VertragModel->addSelect('person_id');
// Check if user is entitled to accept this Lehrauftrag
// * first retrieve person_id of the contract
$this->VertragModel->addSelect('person_id');
if ($result = getData($this->VertragModel->load($vertrag_id)))
{
// * then find the uid of that contracts person_id
$this->BenutzerModel->addSelect('uid');
if ($result = getData($this->VertragModel->load($vertrag_id)))
{
// * then find the uid of that contracts person_id
$this->BenutzerModel->addSelect('uid');
if ($result = getData($this->BenutzerModel->getFromPersonId($result[0]->person_id)))
{
// * finally check uid of contract against the logged in user
if ($result = getData($this->BenutzerModel->getFromPersonId($result[0]->person_id)))
{
// * finally check uid of contract against the logged in user
$account_found = false;
foreach($result as $row_accounts)
foreach ($result as $row_accounts)
{
if($row_accounts->uid == $this->_uid)
if ($row_accounts->uid == $this->_uid)
{
$account_found = true;
}
}
if (!$account_found)
{
if (!$account_found)
{
return $this->outputJsonError('Sie haben keine Berechtigung für einen Vertrag');
}
}
else
{
}
}
else
{
return $this->outputJsonError('Fehler beim Laden der Benutzerdaten');
}
}
else
{
}
}
else
{
return $this->outputJsonError('Fehler beim Laden des Vertrags');
}
}
// Set status to accepted
$result = $this->VertragvertragsstatusModel->setStatus($vertrag_id, $this->_uid, 'akzeptiert');
// Set status to accepted
$result = $this->VertragvertragsstatusModel->setStatus($vertrag_id, $this->_uid, 'akzeptiert');
if ($result->retval)
{
$json []= array(
'row_index' => $lehrauftrag['row_index'],
'akzeptiert' => date('Y-m-d')
);
}
if ($result->retval)
{
$json []= array(
'row_index' => $lehrauftrag['row_index'],
'akzeptiert' => date('Y-m-d')
);
}
else
{
return $this->outputJsonError($result->retval);
}
}
}
// Output json to ajax
if (isset($json) && !isEmptyArray($json))
{
$this->outputJsonSuccess($json);
}
}
// Output json to ajax
if (isset($json) && !isEmptyArray($json))
{
$this->outputJsonSuccess($json);
}
}
else
{
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
}
}
}
/**
* Check if lectors latest Verwendung has inkludierte Lehre
@@ -189,7 +205,7 @@ class LehrauftragAkzeptieren extends Auth_Controller
* - inkludierte_lehre -1: fix employed lector -> has inkludierte Lehre (all inclusive)
* - inkludierte_lehre > 0: fix employed lector -> has inkludierte Lehre (value is amount of hours included)
*/
public function checkInkludierteLehre()
public function checkInkludierteLehre()
{
$result = $this->BisverwendungModel->getLast($this->_uid, false);
@@ -203,17 +219,17 @@ class LehrauftragAkzeptieren extends Auth_Controller
}
}
// -----------------------------------------------------------------------------------------------------------------
// Private methods
// -----------------------------------------------------------------------------------------------------------------
// Private methods
/**
* Retrieve the UID of the logged user and checks if it is valid
*/
private function _setAuthUID()
{
$this->_uid = getAuthUID();
/**
* Retrieve the UID of the logged user and checks if it is valid
*/
private function _setAuthUID()
{
$this->_uid = getAuthUID();
if (!$this->_uid) show_error('User authentification failed');
}
if (!$this->_uid) show_error('User authentification failed');
}
}
@@ -50,7 +50,8 @@ class LehrauftragErteilen extends Auth_Controller
array(
'global',
'ui',
'lehre'
'lehre',
'table'
)
);
+8 -83
View File
@@ -7,60 +7,34 @@ class FAS_UDF extends Auth_Controller
const FAS_UDF_SESSION_NAME = 'fasUdfSessionName';
public function __construct()
{
parent::__construct(
{
parent::__construct(
array(
'index' => 'basis/person:r',
'saveUDF' => 'basis/person:rw'
)
);
$this->load->model('person/Person_model', 'PersonModel');
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
}
}
/**
*
*/
public function index()
{
$fasUdfSession = getSession(self::FAS_UDF_SESSION_NAME);
$person_id = $this->input->get('person_id');
if (isset($fasUdfSession['person_id']))
{
if (!isset($person_id))
{
$person_id = $fasUdfSession['person_id'];
}
unset($fasUdfSession['person_id']);
}
$prestudent_id = $this->input->get('prestudent_id');
if (isset($fasUdfSession['prestudent_id']))
{
if (!isset($prestudent_id))
{
$prestudent_id = $fasUdfSession['prestudent_id'];
}
unset($fasUdfSession['prestudent_id']);
}
$result = null;
if (isset($fasUdfSession['result']))
{
$result = clone $fasUdfSession['result'];
setSessionElement(self::FAS_UDF_SESSION_NAME, 'result', null);
}
$data = array('result' => $result);
$data = array();
if (isset($person_id) && is_numeric($person_id))
{
if ($this->PersonModel->hasUDF())
{
$personUdfs = $this->PersonModel->getUDFs($person_id);
$personUdfs['person_id'] = $person_id;
$data['person_id'] = $person_id;
$data['personUdfs'] = $personUdfs;
}
}
@@ -70,61 +44,12 @@ class FAS_UDF extends Auth_Controller
if ($this->PrestudentModel->hasUDF())
{
$prestudentUdfs = $this->PrestudentModel->getUDFs($prestudent_id);
$prestudentUdfs['prestudent_id'] = $prestudent_id;
$data['prestudent_id'] = $prestudent_id;
$data['prestudentUdfs'] = $prestudentUdfs;
}
}
$this->load->view('system/fas_udf', $data);
}
/**
*
*/
public function saveUDF()
{
$udfs = $this->input->post();
$validation = $this->_validate($udfs);
$userdata = array(
'person_id' => $this->input->post('person_id'),
'prestudent_id' => $this->input->post('prestudent_id')
);
if (isSuccess($validation))
{
// Load model UDF_model
$this->load->model('system/FAS_UDF_model', 'FASUDFModel');
$result = $this->FASUDFModel->saveUDFs($udfs);
$userdata['result'] = $result;
}
else
{
$userdata['result'] = $validation;
}
setSessionElement(self::FAS_UDF_SESSION_NAME, 'person_id', $userdata['person_id']);
setSessionElement(self::FAS_UDF_SESSION_NAME, 'prestudent_id', $userdata['prestudent_id']);
setSessionElement(self::FAS_UDF_SESSION_NAME, 'result', $userdata['result']);
redirect('system/FAS_UDF');
}
/**
*
*/
private function _validate($udfs)
{
$validation = error('person_id or prestudent_id is missing');
if((isset($udfs['person_id']) && !(is_null($udfs['person_id'])) && ($udfs['person_id'] != ''))
|| (isset($udfs['prestudent_id']) && !(is_null($udfs['prestudent_id'])) && ($udfs['prestudent_id'] != '')))
{
$validation = success(true);
}
return $validation;
}
}
@@ -35,7 +35,7 @@ class LogsViewer extends Auth_Controller
// Public methods
/**
* Main page of the InfoCenter tool
* Everything has a beginning
*/
public function index()
{
@@ -1337,7 +1337,7 @@ class InfoCenter extends Auth_Controller
show_error(getError($prestudentWithZgv));
}
$zgvpruefung = $prestudentWithZgv->retval[0];
$zgvpruefung = getData($prestudentWithZgv);
if (isset($zgvpruefung->prestudentstatus))
{
@@ -1362,11 +1362,15 @@ class InfoCenter extends Auth_Controller
$zgvpruefung->isRtFreigegeben = false;
$zgvpruefung->isStgFreigegeben = false;
$zgvpruefung->sendStgFreigabeMsg = true;//wether Stgudiengangfreigabemessage can be sent (for "exceptions", Studiengänge with no message sending)
$this->PrestudentstatusModel->addSelect('bestaetigtam, statusgrund_id, tbl_status_grund.bezeichnung_mehrsprachig AS bezeichnung_statusgrund');
$this->PrestudentstatusModel->addJoin('public.tbl_status_grund', 'statusgrund_id', 'LEFT');
$isFreigegeben = $this->PrestudentstatusModel->loadWhere(array('studiensemester_kurzbz' => $zgvpruefung->prestudentstatus->studiensemester_kurzbz,
'tbl_prestudentstatus.status_kurzbz' => self::INTERESSENTSTATUS, 'prestudent_id' => $prestudent->prestudent_id));
$isFreigegeben = null;
if (isset($zgvpruefung->prestudentstatus->studiensemester_kurzbz))
{
$this->PrestudentstatusModel->addSelect('bestaetigtam, statusgrund_id, tbl_status_grund.bezeichnung_mehrsprachig AS bezeichnung_statusgrund');
$this->PrestudentstatusModel->addJoin('public.tbl_status_grund', 'statusgrund_id', 'LEFT');
$isFreigegeben = $this->PrestudentstatusModel->loadWhere(array('studiensemester_kurzbz' => $zgvpruefung->prestudentstatus->studiensemester_kurzbz,
'tbl_prestudentstatus.status_kurzbz' => self::INTERESSENTSTATUS, 'prestudent_id' => $prestudent->prestudent_id));
}
if (hasData($isFreigegeben))
{
@@ -1537,9 +1541,10 @@ class InfoCenter extends Auth_Controller
show_error(getError($prestudent));
}
$person_id = $prestudent->retval[0]->person_id;
$studiengang_kurzbz = $prestudent->retval[0]->studiengang;
$studiengang_bezeichnung = $prestudent->retval[0]->studiengangbezeichnung;
$prestudentdata = getData($prestudent);
$person_id = $prestudentdata->person_id;
$studiengang_kurzbz = $prestudentdata->studiengang;
$studiengang_bezeichnung = $prestudentdata->studiengangbezeichnung;
return array('person_id' => $person_id, 'studiengang_kurzbz' => $studiengang_kurzbz, 'studiengang_bezeichnung' => $studiengang_bezeichnung);
}
@@ -1582,7 +1587,8 @@ class InfoCenter extends Auth_Controller
private function _sendFreigabeMail($prestudent_id)
{
//get data
$prestudent = $this->PrestudentModel->getPrestudentWithZgv($prestudent_id)->retval[0];
$prestudent = $this->PrestudentModel->getPrestudentWithZgv($prestudent_id);
$prestudent = getData($prestudent);
$prestudentstatus = $prestudent->prestudentstatus;
$person_id = $prestudent->person_id;
$person = $this->PersonModel->getPersonStammdaten($person_id, true)->retval;
@@ -0,0 +1,130 @@
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* This controller acts as REST JSON interface between the JobsQueueLib, that contains all the needed functionalities to
* operate with the Jobs Queue System, and other tools that cannot access directly to such library
*/
class JobsQueueManager extends Auth_Controller
{
// Config entry name for White list of permissions...
const JOB_TYPE_PERMISSIONS_WHITE_LIST = 'job_type_permissions_white_list';
// Parameter names
const PARAM_JOBS = 'jobs';
/**
* Constructor
*/
public function __construct()
{
parent::__construct(
array(
'getLastJobs' => 'admin:r',
'addNewJobsToQueue' => 'admin:rw',
'updateJobsQueue' => 'admin:rw'
)
);
// Loading config file jqm
$this->config->load('jqm');
// Loads JobsQueueLib
$this->load->library('JobsQueueLib');
// Loads permission lib
$this->load->library('PermissionLib');
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* To get all the most recently added jobs using the given job type
*/
public function getLastJobs()
{
$type = $this->input->get(JobsQueueLib::PROPERTY_TYPE);
$this->_checkPermissions($type);
$this->outputJson($this->jobsqueuelib->getLastJobs($type));
}
/**
* Add new jobs in the jobs queue with the given type
* jobs is an array of job objects
*/
public function addNewJobsToQueue()
{
$type = $this->input->post(JobsQueueLib::PROPERTY_TYPE);
$jobs = $this->input->post(self::PARAM_JOBS);
$this->_checkPermissions($type);
// Otherwise convert jobs from json to php and call JobsQueueLib library
$this->outputJson($this->jobsqueuelib->addNewJobsToQueue($type, $this->_convertJobs($jobs)));
}
/**
* Add new jobs in the jobs queue with the given type
* jobs is an array of job objects
*/
public function updateJobsQueue()
{
$type = $this->input->post(JobsQueueLib::PROPERTY_TYPE);
$jobs = $this->input->post(self::PARAM_JOBS);
$this->_checkPermissions($type);
// Otherwise convert jobs from json to php and call JobsQueueLib library
$this->outputJson($this->jobsqueuelib->updateJobsQueue($type, $this->_convertJobs($jobs)));
}
//------------------------------------------------------------------------------------------------------------------
// Private methods
/**
*
*/
private function _checkPermissions($type)
{
// Checks if the caller has the permissions to add new jobs with the given type in the queue
if (!$this->permissionlib->isEntitled($this->config->item(self::JOB_TYPE_PERMISSIONS_WHITE_LIST), $type))
{
// Permissions NOT valid
$this->terminateWithJsonError('You are not allowed to access to this content');
}
}
/**
*
*/
private function _convertJobs($jobs)
{
if (isEmptyArray($jobs)) return null; // if not a valid array then return null
$convertedJobsArray = array(); // returned values
// Loops through all the provided jobs
foreach ($jobs as $job)
{
$tmpObj = json_decode($job); // Try to decode json to php
// If decode was a success
if ($tmpObj != null)
{
$convertedJobsArray[] = $tmpObj; // then store the decoded object in the result array
}
else // otherwise
{
// Create a new object and store the error message in it
$tmpObj = new stdClass();
$tmpObj->{JobsQueueLib::PROPERTY_ERROR} = 'A not valid json was provided';
$convertedJobsArray[] = $tmpObj; // store this object into the result array
}
}
return $convertedJobsArray;
}
}
@@ -0,0 +1,51 @@
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* Jobs Queue Viewer
*
* This controller renders a FilterWidget to monitor the current status of the Jobs Queue System
*/
class JobsQueueViewer extends Auth_Controller
{
const PARAM_START_DATE = 'startDate';
/**
* Constructor
*/
public function __construct()
{
parent::__construct(
array(
'index' => 'system/developer:r'
)
);
// Loads WidgetLib
$this->load->library('WidgetLib');
// Loads JobsQueueLib
$this->load->library('JobsQueueLib');
// Loads phrases system
$this->loadPhrases(
array(
'global',
'ui',
'filter'
)
);
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* Everything has a beginning
*/
public function index()
{
$this->load->view('system/jq/jobsQueueViewer.php');
}
}
+2 -2
View File
@@ -4,7 +4,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* This controller operates between (interface) the JS (GUI) and the FilterWidgetLib (back-end)
* Provides data to the ajax get calls about the filter
* Provides data to the ajax get calls about the filter widget
* Accepts ajax post calls to change the filter data
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
* NOTE: extends the FHC_Controller instead of the Auth_Controller because the FilterWidget has its
@@ -12,7 +12,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
*/
class Filters extends FHC_Controller
{
const FILTER_UNIQUE_ID = 'filterUniqueId';
const FILTER_UNIQUE_ID = 'filterUniqueId'; // Name of the filter widget unique id
/**
* Calls the parent's constructor and loads the FilterWidgetLib
+2 -2
View File
@@ -4,7 +4,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* This controller operates between (interface) the JS (GUI) and the tablewidgetlib (back-end)
* Provides data to the ajax get calls about the filter
* Provides data to the ajax get calls about the table widget
* Accepts ajax post calls to change the filter data
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
* NOTE: extends the FHC_Controller instead of the Auth_Controller because the TableWidget has its
@@ -12,7 +12,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
*/
class Tables extends FHC_Controller
{
const TABLE_UNIQUE_ID = 'tableUniqueId';
const TABLE_UNIQUE_ID = 'tableUniqueId'; // Name of the table widget unique id
/**
* Calls the parent's constructor and loads the tablewidgetlib
+107
View File
@@ -0,0 +1,107 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* This controller operates between (interface) the JS (GUI) and the UDFLib (back-end)
* Provides data to the ajax get calls about the UDF widget
* Accepts ajax post calls to save UDFs
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
* NOTE: extends the FHC_Controller instead of the Auth_Controller because the UDFWidget has its
* own permissions check
*/
class UDF extends FHC_Controller
{
const UDF_UNIQUE_ID = 'udfUniqueId'; // Name of the udf widget unique id
/**
* Calls the parent's constructor and loads the UDFLib
*/
public function __construct()
{
parent::__construct();
// Loads authentication library and starts authentication
$this->load->library('AuthLib');
// Loads the UDFLib with HTTP GET/POST parameters
$this->_loadUDFLib();
// Checks if the caller is allow to use this UDF widget
$this->_isAllowed();
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* Save data about the current UDFs and the result will be written on the output in JSON format
*/
public function saveUDFs()
{
$udfUniqueId = $this->input->post(self::UDF_UNIQUE_ID);
$udfs = $this->input->post(UDFLib::UDFS_ARG_NAME);
if (!isEmptyString($udfs))
{
$jsonDecodedUDF = json_decode($udfs);
if ($jsonDecodedUDF != null)
{
$this->outputJson($this->udflib->saveUDFs($udfUniqueId, $jsonDecodedUDF));
}
else
{
$this->outputJsonError('No valid JSON format for UDF values');
}
}
else
{
$this->outputJsonError('UDFUniqueId, schema, table name, primary key name and primary key value are mandatory paramenters');
}
}
//------------------------------------------------------------------------------------------------------------------
// Private methods
/**
* Checks if the user is allowed to use this UDFWidget
*/
private function _isAllowed()
{
if (!$this->udflib->isAllowed())
{
$this->terminateWithJsonError('You are not allowed to access to this content');
}
}
/**
* Loads the UDFLib with the UDF_UNIQUE_ID parameter
* If the parameter UDF_UNIQUE_ID is not given then the execution of the controller is terminated and
* an error message is printed
*/
private function _loadUDFLib()
{
// If the parameter UDF_UNIQUE_ID is present in the HTTP GET or POST
if (isset($_GET[self::UDF_UNIQUE_ID]) || isset($_POST[self::UDF_UNIQUE_ID]))
{
// If it is present in the HTTP GET
if (isset($_GET[self::UDF_UNIQUE_ID]))
{
$udfUniqueId = $this->input->get(self::UDF_UNIQUE_ID); // is retrieved from the HTTP GET
}
elseif (isset($_POST[self::UDF_UNIQUE_ID])) // Else if it is present in the HTTP POST
{
$udfUniqueId = $this->input->post(self::UDF_UNIQUE_ID); // is retrieved from the HTTP POST
}
// Loads the UDFLib that contains all the used logic
$this->load->library('UDFLib');
$this->udflib->setUDFUniqueId($udfUniqueId);
}
else // Otherwise an error will be written in the output
{
$this->terminateWithJsonError('Parameter "'.self::UDF_UNIQUE_ID.'" not provided!');
}
}
}