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
+1
View File
@@ -9,6 +9,7 @@ $config['msg_delivery'] = true; // Default true
$config['system_person_id'] = 1; // Dummy sender, used for sending messages from the system
$config['redirect_view_message_url'] = 'index.ci.php/Redirect/redirectByToken/'; //
$config['message_html_view_url'] = 'index.ci.php/ViewMessage/toHTML/';
$config['message_server'] = 'http://www.fhcomplete.org/';
$config['assistent_function'] = 'ass';
define('EMAIL_KONTAKT_TYPE', 'email'); // Email kontakt type
@@ -53,10 +53,11 @@ class Dms extends APIv1_Controller
{
$person_id = $this->get('person_id');
$dokument_kurzbz = $this->get('dokument_kurzbz');
$no_file = $this->get('no_file');
if (isset($person_id))
{
$result = $this->dmslib->getAktenAcceptedDms($person_id, $dokument_kurzbz);
$result = $this->dmslib->getAktenAcceptedDms($person_id, $dokument_kurzbz, $no_file);
$this->response($result, REST_Controller::HTTP_OK);
}
+28 -7
View File
@@ -40,14 +40,13 @@ class Messages extends VileSci_Controller
}
// Get variables
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
$prestudent = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id);
if ($prestudent->error)
$this->load->model('system/Message_model', 'MessageModel');
$msgVarsDataByPrestudentId = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id);
if ($msgVarsDataByPrestudentId->error)
{
show_error($prestudent->retval);
show_error($msgVarsDataByPrestudentId->retval);
}
$this->load->model('system/Message_model', 'MessageModel');
if (!hasData($variables = $this->MessageModel->getMessageVars()))
{
unset($variables);
@@ -65,11 +64,33 @@ class Messages extends VileSci_Controller
array_shift($variables->retval); // Remove person_id
array_shift($variables->retval); // Remove prestudent_id
// Organisation units
$oe_kurzbz = array(); // A person can have more organisation units
$this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
$benutzerResult = $this->BenutzerfunktionModel->getByPersonId($sender_id);
if (hasData($benutzerResult))
{
foreach($benutzerResult->retval as $val)
{
$oe_kurzbz[] = $val->oe_kurzbz;
}
}
// Admin or commoner?
$this->load->model('system/Benutzerrolle_model', 'BenutzerrolleModel');
$isAdmin = $this->BenutzerrolleModel->isAdminByPersonId($sender_id);
if (isError($isAdmin))
{
show_error($isAdmin->retval);
}
$data = array (
'sender_id' => $sender_id,
'receivers' => $prestudent->retval,
'receivers' => $msgVarsDataByPrestudentId->retval,
'message' => $msg,
'variables' => $variablesArray
'variables' => $variablesArray,
'oe_kurzbz' => $oe_kurzbz,
'isAdmin' => $isAdmin->retval
);
$v = $this->load->view('system/messageWrite', $data);
+4 -2
View File
@@ -2,13 +2,15 @@
require_once APPPATH . '/libraries/REST_Controller.php';
class APIv1_Controller extends REST_Controller
class APIv1_Controller extends REST_Controller
{
function __construct()
function __construct()
{
parent::__construct();
// Loads return messages
$this->load->helper('message');
log_message('debug', 'Called API: '.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']);
}
}
+14
View File
@@ -62,3 +62,17 @@ function generateToken($length = 64)
$token .= $characters[mt_rand(0, $charactersLength)];
return $token;
}
/**
* var_dump_to_error_log()
* Gets the output of the var_dump function and print it out
* via the error log. It also removes the end line characters
*/
function var_dump_to_error_log($parameter)
{
ob_start();
var_dump($parameter);
$ob_get_contents = ob_get_contents();
ob_end_clean();
error_log(str_replace("\n", '', $ob_get_contents));
}
+2 -1
View File
@@ -11,7 +11,8 @@
* @filesource
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
require_once FCPATH.'include/authentication.class.php';
require_once FHCPATH.'include/authentication.class.php';
/**
* FHC-Auth Helpers
+2 -2
View File
@@ -68,11 +68,11 @@ class DmsLib
/**
*
*/
public function getAktenAcceptedDms($person_id, $dokument_kurzbz = null)
public function getAktenAcceptedDms($person_id, $dokument_kurzbz = null, $no_file = null)
{
$result = $this->ci->AkteModel->getAktenAcceptedDms($person_id, $dokument_kurzbz);
if (hasData($result))
if (hasData($result) && $no_file == null)
{
for ($i = 0; $i < count($result->retval); $i++)
{
+3 -2
View File
@@ -11,8 +11,9 @@
* @filesource
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
require_once FCPATH.'include/authentication.class.php';
require_once FCPATH.'include/AddonAuthentication.php';
require_once FHCPATH.'include/authentication.class.php';
require_once FHCPATH.'include/AddonAuthentication.php';
/**
* FHC-Auth Helpers
+2 -2
View File
@@ -453,7 +453,7 @@ class MessageLib
// If the person has an email account
if (!is_null($result->retval[$i]->receiver) && $result->retval[$i]->receiver != '')
{
$href = APP_ROOT . $this->ci->config->item('message_html_view_url') . $result->retval[0]->token;
$href = $this->ci->config->item('message_server') . $this->ci->config->item('message_html_view_url') . $result->retval[0]->token;
// Using a template for the html email body
$body = $this->ci->parser->parse(
'templates/mailHTML',
@@ -588,7 +588,7 @@ class MessageLib
if ($multiPartMime === true)
{
// Using a template for the html email body
$href = APP_ROOT . $this->ci->config->item('message_html_view_url') . $result->retval[0]->token;
$href = $this->ci->config->item('message_server') . $this->ci->config->item('message_html_view_url') . $result->retval[0]->token;
$bodyMsg = $this->ci->parser->parse(
'templates/mailHTML',
array(
@@ -59,7 +59,48 @@ class OrganisationseinheitLib
return $this->treeSearch($schema, $table, $select, $where, $orderby, $result->retval[0]->_ppk);
}
}
return $result;
}
public function treeSearchEntire($table, $alias, $fields, $where, $orderby, $oe_kurzbz)
{
$select = "";
if (is_array($fields))
{
for ($i = 0; $i < count($fields); $i++)
{
$select .= $fields[$i];
if ($i != count($fields) - 1)
{
$select .= ", ";
}
}
}
else
{
$select = $fields;
}
$result = $this->ci->OrganisationseinheitModel->getOneLevelAlias($table, $alias, $select, $where, $orderby, $oe_kurzbz);
if (hasData($result))
{
if ($result->retval[0]->_pk != null && $result->retval[0]->_ppk != null && $result->retval[0]->_jtpk != null)
{
$tmpResult = $this->treeSearchEntire($table, $alias, $select, $where, $orderby, $result->retval[0]->_ppk);
if (hasData($tmpResult) && $tmpResult->retval[0]->_pk != null && $tmpResult->retval[0]->_ppk != null && $tmpResult->retval[0]->_jtpk != null)
{
$result->retval = array_merge($result->retval, $tmpResult->retval);
}
}
else if ($result->retval[0]->_ppk != null)
{
$result = $this->treeSearchEntire($table, $alias, $select, $where, $orderby, $result->retval[0]->_ppk);
}
}
return $result;
}
}
+34 -30
View File
@@ -11,15 +11,15 @@
* @filesource
*/
if (! defined('FCPATH')) exit('No direct script access allowed');
if (! defined('BASEPATH')) exit('No direct script access allowed');
require_once(FCPATH.'include/basis_db.class.php');
require_once(FCPATH.'include/organisationseinheit.class.php');
require_once(FCPATH.'include/studiengang.class.php');
require_once(FCPATH.'include/fachbereich.class.php');
require_once(FCPATH.'include/functions.inc.php');
require_once(FCPATH.'include/wawi_kostenstelle.class.php');
require_once(FCPATH.'include/benutzerberechtigung.class.php');
require_once(FHCPATH.'include/basis_db.class.php');
require_once(FHCPATH.'include/organisationseinheit.class.php');
require_once(FHCPATH.'include/studiengang.class.php');
require_once(FHCPATH.'include/fachbereich.class.php');
require_once(FHCPATH.'include/functions.inc.php');
require_once(FHCPATH.'include/wawi_kostenstelle.class.php');
require_once(FHCPATH.'include/benutzerberechtigung.class.php');
class PermissionLib
{
@@ -29,34 +29,36 @@ class PermissionLib
const INSERT_RIGHT = 'i';
const DELETE_RIGHT = 'd';
const REPLACE_RIGHT = 'ui';
private $bb; // benutzerberechtigung
private $acl; // conversion array from a source to a permission
private static $bb; // benutzerberechtigung
/**
*
* PermissionLib's constructor
* Here is initialized the static property bb with all the rights of the user (API caller)
*/
function __construct()
{
// Loads CI instance
$this->ci =& get_instance();
// Loads the library to manage the rights system
//$this->ci->load->library('FHC_DB_ACL');
// Loads the auth helper
$this->ci->load->helper('fhcauth');
// Loads the array of resources
$this->acl = $this->ci->config->item('fhc_acl');
//
$this->bb = new benutzerberechtigung();
// API Caller rights initialization
self::$bb = new benutzerberechtigung();
self::$bb->getBerechtigungen(getAuthUID());
}
/**
* Check if the user is entitled to get access to a source with the given access type
*
*
* @return bool <b>true</b> if a user has the right to access to the specified
* resource with a specified permission type, <b>false</b> otherwise
*/
@@ -66,7 +68,7 @@ class PermissionLib
if (isset($this->acl[$sourceName]))
{
// Checks permission
return $this->isBerechtigt($this->acl[$sourceName], $permissionType);
return $this->_isBerechtigt($this->acl[$sourceName], $permissionType);
}
// if the resource does not exist, do not lose useful clock cycles
else
@@ -74,7 +76,7 @@ class PermissionLib
return false;
}
}
/**
* Get a permission by a given source
*/
@@ -89,20 +91,22 @@ class PermissionLib
return null;
}
}
/**
*
* Checks user's (API caller) rights
*/
private function isBerechtigt($berechtigung_kurzbz, $art = null, $oe_kurzbz = null, $kostenstelle_id = null)
private function _isBerechtigt($berechtigung_kurzbz, $art = null, $oe_kurzbz = null, $kostenstelle_id = null)
{
$isBerechtigt = false;
if (!is_null($berechtigung_kurzbz))
{
$this->bb->getBerechtigungen(getAuthUID());
return $this->bb->isBerechtigt($berechtigung_kurzbz, $oe_kurzbz, $art, $kostenstelle_id);
}
else
{
return false;
if(self::$bb->isBerechtigt($berechtigung_kurzbz, $oe_kurzbz, $art, $kostenstelle_id))
{
$isBerechtigt = true;
}
}
return $isBerechtigt;
}
}
+23 -1
View File
@@ -23,7 +23,14 @@ class ReihungstestLib
*/
public function insertPersonReihungstest($ddReihungstest)
{
return $this->ci->RtPersonModel->insert($ddReihungstest);
if (isset($ddReihungstest['rt_id']) && $this->checkAvailability($ddReihungstest['rt_id']))
{
return $this->ci->RtPersonModel->insert($ddReihungstest);
}
else
{
return error('This test is not more available');
}
}
/**
@@ -62,4 +69,19 @@ class ReihungstestLib
return $this->ci->ReihungstestModel->loadWhere($parametersArray);
}
/**
* It checks if the test is available
*/
public function checkAvailability($reihungstest_id)
{
$result = $this->ci->ReihungstestModel->checkAvailability($reihungstest_id);
if (hasData($result))
{
return true;
}
return false;
}
}
@@ -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;
}
}
+1 -1
View File
@@ -93,7 +93,7 @@
<?php
echo $this->widgetlib->widget(
'Vorlage_widget',
null,
array('oe_kurzbz' => $oe_kurzbz, 'isAdmin' => $isAdmin),
array('name' => 'vorlage', 'id' => 'vorlageDnD')
);
?>
+111 -4
View File
@@ -4,13 +4,28 @@ class Vorlage_widget extends DropdownWidget
{
public function display($widgetData)
{
$this->load->model('system/Vorlage_model', 'VorlageModel');
$this->VorlageModel->addOrder('vorlage_kurzbz');
// All organization units to which the user belongs
$oe_kurzbz = $widgetData['oe_kurzbz'];
$idAdmin = $widgetData['isAdmin'];
$this->addSelectToModel($this->VorlageModel, 'vorlage_kurzbz', 'bezeichnung');
$vorlage = null;
// If the user is an admin
if ($idAdmin === true)
{
// Get all the vorlage with mimetype = text/html
$vorlage = $this->_getAllHTMLVorlage();
}
else
{
// Get all the vorlage that belongs to the organisation units of the user
// and the parents of those organisation units until the root of the
// organisation unit tree
$vorlage = $this->_getUserVorlage($oe_kurzbz);
}
$this->setElementsArray(
$this->VorlageModel->loadWhere(array('mimetype' => 'text/html')),
$vorlage,
true,
'Select a vorlage...',
'No vorlage found'
@@ -18,4 +33,96 @@ class Vorlage_widget extends DropdownWidget
$this->loadDropDownView($widgetData);
}
/**
* Get all the vorlage with mimetype = text/html
*/
private function _getAllHTMLVorlage()
{
$this->load->model('system/Vorlage_model', 'VorlageModel');
$this->VorlageModel->addOrder('vorlage_kurzbz');
$this->addSelectToModel($this->VorlageModel, 'vorlage_kurzbz', 'bezeichnung');
return $this->VorlageModel->loadWhere(array('mimetype' => 'text/html'));
}
/**
* Get all the vorlage that belongs to the organisation units of the user
* and the parents of those organisation units until the root of the
* organisation unit tree
*/
private function _getUserVorlage($oe_kurzbz)
{
// Loads library OrganisationseinheitLib
$this->load->library('OrganisationseinheitLib');
$vorlage = success(array()); // Default value
$table = '(
SELECT v.vorlage_kurzbz, v.bezeichnung, vs.version, vs.oe_kurzbz, vs.aktiv, vs.subject, vs.text, v.mimetype
FROM tbl_vorlagestudiengang vs INNER JOIN tbl_vorlage v USING(vorlage_kurzbz)
) templates';
$alias = 'templates';
$fields = array("templates.vorlage_kurzbz AS id", "UPPER(templates.oe_kurzbz) || ' - ' || templates.bezeichnung || ' - V' || templates.version AS description");
$where = 'templates.aktiv = TRUE
AND templates.subject IS NOT NULL
AND templates.text IS NOT NULL
AND templates.mimetype = \'text/html\'';
$order_by = 'description ASC';
if (!is_array($oe_kurzbz))
{
$vorlage = $this->organisationseinheitlib->treeSearchEntire(
$table,
$alias,
$fields,
$where,
$order_by,
$oe_kurzbz
);
}
else // is an array
{
// Get the vorlage for each organisation unit
foreach($oe_kurzbz as $val)
{
$tmpVorlage = $this->organisationseinheitlib->treeSearchEntire(
$table,
$alias,
$fields,
$where,
$order_by,
$val
);
// Everything is ok and data are inside
if (hasData($tmpVorlage))
{
// If it's the first vorlage copy it
if (count($vorlage->retval) == 0)
{
$vorlage->retval = $tmpVorlage->retval;
}
else // checks for duplicates, if it's not already present push it into the array $vorlage->retval
{
for ($i = 0; $i < count($vorlage->retval); $i++)
{
for ($j = 0; $j < count($tmpVorlage->retval); $j++)
{
if ($vorlage->retval[$i]->_pk != $tmpVorlage->retval[$j]->_pk
&& $vorlage->retval[$i]->_ppk != $tmpVorlage->retval[$j]->_ppk
&& $vorlage->retval[$i]->_jtpk != $tmpVorlage->retval[$j]->_jtpk)
{
array_push($vorlage->retval, $tmpVorlage->retval[$j]);
}
}
}
}
}
}
}
return $vorlage;
}
}