mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
f3b79cd731
- Added method toPhp to DB_Model to convert array and boolean types from PostgresSQL to php - Added method execQuery to DB_Model to execute a query (it calls toPhp) - Added method pgsqlArrayToPhpArray to convert a pgsql array to php - Updated DB_Model methods to using chkRights (and toPhp where it is needed) - Removed methods escapeArray and _pgsqlArrayToPhpArray from controller APIv1_Controller - Removed escapeArray from controllers Dokumentstudiengang and Dokument - Updated models to use execQuery (and chkRights where it is needed)
94 lines
3.1 KiB
PHP
94 lines
3.1 KiB
PHP
<?php
|
|
|
|
class Person_model extends DB_Model
|
|
{
|
|
/**
|
|
*
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->dbTable = 'public.tbl_person';
|
|
$this->pk = 'person_id';
|
|
}
|
|
|
|
public function getPersonKontaktByZugangscode($zugangscode, $email)
|
|
{
|
|
$this->addJoin('public.tbl_kontakt', 'person_id');
|
|
|
|
return $this->loadWhere(array('zugangscode' => $zugangscode, 'kontakt' => $email));
|
|
}
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public function checkBewerbung($email, $studiensemester_kurzbz = null)
|
|
{
|
|
if (($chkRights = $this->isEntitled('public.tbl_person', 's', FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
|
return $chkRights;
|
|
if (($chkRights = $this->isEntitled('public.tbl_kontakt', 's', FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
|
return $chkRights;
|
|
if (($chkRights = $this->isEntitled('public.tbl_benutzer', 's', FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
|
return $chkRights;
|
|
if (($chkRights = $this->isEntitled('public.tbl_prestudent', 's', FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
|
return $chkRights;
|
|
if (($chkRights = $this->isEntitled('public.tbl_prestudentstatus', 's', FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
|
|
return $chkRights;
|
|
|
|
$checkBewerbungQuery = '';
|
|
$parametersArray = array($email, $email, $email);
|
|
|
|
if (is_null($studiensemester_kurzbz))
|
|
{
|
|
$checkBewerbungQuery = 'SELECT DISTINCT p.person_id, p.zugangscode, p.insertamum
|
|
FROM public.tbl_person p JOIN public.tbl_kontakt k ON p.person_id = k.person_id
|
|
LEFT JOIN public.tbl_benutzer b ON p.person_id = b.person_id
|
|
WHERE k.kontakttyp = \'email\'
|
|
AND (kontakt = ? OR alias || \'@' . DOMAIN . '\' = ? OR uid || \'@' . DOMAIN . '\' = ?)
|
|
ORDER BY p.insertamum DESC
|
|
LIMIT 1';
|
|
}
|
|
else
|
|
{
|
|
$checkBewerbungQuery = 'SELECT DISTINCT p.person_id, p.zugangscode, p.insertamum
|
|
FROM public.tbl_person p JOIN public.tbl_kontakt k ON p.person_id = k.person_id
|
|
LEFT JOIN public.tbl_benutzer b ON p.person_id = b.person_id
|
|
JOIN public.tbl_prestudent ps ON p.person_id = ps.person_id
|
|
JOIN public.tbl_prestudentstatus pst ON pst.prestudent_id = ps.prestudent_id
|
|
WHERE k.kontakttyp = \'email\'
|
|
AND (kontakt = ? OR alias || \'@' . DOMAIN . '\' = ? OR uid || \'@' . DOMAIN . '\' = ?)
|
|
AND studiensemester_kurzbz = ?
|
|
ORDER BY p.insertamum DESC
|
|
LIMIT 1';
|
|
|
|
array_push($parametersArray, $studiensemester_kurzbz);
|
|
}
|
|
|
|
return $this->execQuery($checkBewerbungQuery, $parametersArray);
|
|
}
|
|
|
|
public function updatePerson($person)
|
|
{
|
|
if (isset($person['svnr']) && $person['svnr'] != '')
|
|
{
|
|
$this->PersonModel->addOrder('svnr', 'DESC');
|
|
$result = $this->PersonModel->loadWhere(array(
|
|
'person_id != ' => $person['person_id'],
|
|
'SUBSTRING(svnr FROM 1 FOR 10) = ' => $person['svnr'])
|
|
);
|
|
if (hasData($result))
|
|
{
|
|
if (count($result->retval) == 1 && $result->retval[0]->svnr == $person['svnr'])
|
|
{
|
|
$person['svnr'] = $person['svnr'] . 'v1';
|
|
}
|
|
else
|
|
{
|
|
$person['svnr'] = $person['svnr'] . 'v' . ($result->retval[0]->svnr{11} + 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
return $this->PersonModel->update($person['person_id'], $person);
|
|
}
|
|
} |