Merge branch 'master' into udf

This commit is contained in:
Paolo
2017-06-28 12:07:41 +02:00
139 changed files with 12096 additions and 10712 deletions
@@ -11,4 +11,31 @@ class Reihungstest_model extends DB_Model
$this->dbTable = 'public.tbl_reihungstest';
$this->pk = 'reihungstest_id';
}
/**
* Gets a test from a test id only if it is available
*/
public function checkAvailability($reihungstest_id)
{
$query = 'SELECT public.tbl_reihungstest.*
FROM public.tbl_reihungstest LEFT JOIN public.tbl_rt_studienplan USING(reihungstest_id)
WHERE tbl_reihungstest.oeffentlich = TRUE
AND tbl_reihungstest.datum > NOW()
AND tbl_reihungstest.anmeldefrist >= NOW()
AND COALESCE (
tbl_reihungstest.max_teilnehmer,
(
SELECT SUM(arbeitsplaetze)
FROM public.tbl_ort JOIN public.tbl_rt_ort USING(ort_kurzbz)
WHERE rt_id = tbl_reihungstest.reihungstest_id
)
) - (
SELECT COUNT(*)
FROM public.tbl_rt_person
WHERE rt_id = tbl_reihungstest.reihungstest_id
) > 0
AND reihungstest_id = ?';
return $this->execQuery($query, array($reihungstest_id));
}
}
@@ -78,9 +78,34 @@ class Organisationseinheit_model extends DB_Model
) _joined_table ON (orgs._pk = _joined_table._pk)
WHERE orgs._pk = ?
ORDER BY %s";
$query = sprintf($query, $table, $fields, $schema, $table, $where, $orderby);
return $this->execQuery($query, array($oe_kurzbz));
}
}
public function getOneLevelAlias($table, $alias, $fields, $where, $orderby, $oe_kurzbz)
{
$query = "WITH RECURSIVE organizations(_pk, _ppk) AS
(
SELECT o.oe_kurzbz, o.oe_parent_kurzbz
FROM public.tbl_organisationseinheit o
WHERE o.oe_parent_kurzbz IS NULL
UNION ALL
SELECT o.oe_kurzbz, o.oe_parent_kurzbz
FROM public.tbl_organisationseinheit o INNER JOIN organizations orgs ON (o.oe_parent_kurzbz = orgs._pk)
)
SELECT orgs._pk, orgs._ppk, _joined_table.*
FROM organizations orgs LEFT JOIN (
SELECT %s.oe_kurzbz as _jtpk, %s
FROM %s
WHERE %s
) _joined_table ON (orgs._pk = _joined_table._jtpk)
WHERE orgs._pk = ?
ORDER BY %s";
$query = sprintf($query, $alias, $fields, $table, $where, $orderby);
return $this->execQuery($query, array($oe_kurzbz));
}
}
@@ -22,7 +22,7 @@ class Studiengang_model extends DB_Model
return $isEntitled;
if (($isEntitled = $this->isEntitled('bis.tbl_lgartcode', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
return $isEntitled;
$allForBewerbungQuery = 'SELECT DISTINCT studiengang_kz,
typ,
organisationseinheittyp_kurzbz,
@@ -95,7 +95,7 @@ class Studiengang_model extends DB_Model
WHERE t1.onlinebewerbung IS TRUE
AND t1.aktiv IS TRUE
ORDER BY typ, studiengangbezeichnung, tbl_lgartcode.bezeichnung ASC';
return $this->execQuery($allForBewerbungQuery);
}
@@ -110,11 +110,11 @@ class Studiengang_model extends DB_Model
$this->addJoin('lehre.tbl_studienplan', 'studienordnung_id');
// Then join with table lehre.tbl_studienplan_semester on column studienplan_id
$this->addJoin('lehre.tbl_studienplan_semester', 'studienplan_id');
// Ordering by studiengang_kz and studienplan_id
$this->addOrder('public.tbl_studiengang.studiengang_kz');
$this->addOrder('lehre.tbl_studienplan.studienplan_id');
$result = $this->loadTree(
'public.tbl_studiengang',
array(
@@ -130,7 +130,7 @@ class Studiengang_model extends DB_Model
'studienplaene'
)
);
return $result;
}
@@ -156,7 +156,7 @@ class Studiengang_model extends DB_Model
// Ordering by studiengang_kz and studienplan_id
$this->addOrder('public.tbl_studiengang.bezeichnung');
$this->addOrder('lehre.tbl_studienplan.studienplan_id');
$result = $this->loadTree(
'public.tbl_studiengang',
array(
@@ -175,12 +175,12 @@ class Studiengang_model extends DB_Model
'akadgrad'
)
);
return $result;
}
/**
*
*
*/
public function getAppliedStudiengang($person_id, $studiensemester_kurzbz, $titel)
{
@@ -200,10 +200,10 @@ class Studiengang_model extends DB_Model
'prestudent_id',
'LEFT'
);
// Ordering by studiengang_kz and studienplan_id
$this->addOrder('public.tbl_studiengang.bezeichnung');
$result = $this->loadTree(
'public.tbl_studiengang',
array(
@@ -222,12 +222,12 @@ class Studiengang_model extends DB_Model
'notizen'
)
);
return $result;
}
/**
*
*
*/
public function getAvailableReihungstestByPersonId($person_id)
{
@@ -241,22 +241,22 @@ class Studiengang_model extends DB_Model
return $isEntitled;
if (($isEntitled = $this->isEntitled('public.tbl_prestudent', PermissionLib::SELECT_RIGHT, FHC_NORIGHT, FHC_MODEL_ERROR)) !== true)
return $isEntitled;
$this->addJoin('lehre.tbl_studienordnung', 'studiengang_kz');
$this->addJoin('lehre.tbl_studienplan', 'studienordnung_id');
$this->addJoin('public.tbl_prestudentstatus', 'studienplan_id');
$this->addJoin('public.tbl_prestudent', 'prestudent_id');
$this->addFrom(
'(SELECT * FROM public.tbl_reihungstest LEFT JOIN public.tbl_rt_studienplan USING(reihungstest_id))',
'tbl_reihungstest'
);
$this->addOrder('tbl_studiengang.bezeichnung, tbl_reihungstest.stufe, tbl_reihungstest.datum');
return $this->loadTree(
'public.tbl_studiengang',
array('public.tbl_reihungstest'),
@@ -1,7 +1,7 @@
<?php
class Benutzerfunktion_model extends DB_Model
{
/**
* Constructor
*/
@@ -11,4 +11,15 @@ class Benutzerfunktion_model extends DB_Model
$this->dbTable = 'public.tbl_benutzerfunktion';
$this->pk = 'benutzerfunktion_id';
}
}
/**
* Get the Benutzerfunktion using the person_id
*/
public function getByPersonId($person_id)
{
// Join with the table
$this->addJoin('public.tbl_benutzer', 'uid');
return $this->loadWhere(array('person_id' => $person_id));
}
}
@@ -1,7 +1,7 @@
<?php
class Benutzerrolle_model extends DB_Model
{
/**
* Constructor
*/
@@ -11,4 +11,29 @@ class Benutzerrolle_model extends DB_Model
$this->dbTable = 'system.tbl_benutzerrolle';
$this->pk = 'benutzerberechtigung_id';
}
}
/**
* Checks if the given user is an admin
*/
public function isAdminByPersonId($person_id)
{
// Join with the table tbl_benutzer
$this->addJoin('public.tbl_benutzer', 'uid');
$result = $this->loadWhere(array('person_id' => $person_id, 'rolle_kurzbz' => 'admin'));
if (!isError($result))
{
if (hasData($result))
{
$result = success(true);
}
else if (!hasData($result))
{
$result = success(false);
}
}
return $result;
}
}