mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-03 21:29:28 +00:00
2568d8f912
- Added method escape to class DB_Model - Changed method sendMessageVorlage of MessageLib to send messages trying to use the same language of the receiver, and improved message errors - Added OrganisationseinheitLib to handle a recursive search using in the organisation tree - Removed from PhrasesLib the method loadVorlagetext because is already present in VorlageLib - Changed method loadVorlagetext of VorlageLib, now it searches the template using the organisation tree - Added method getOneLevel to model Organisationseinheit_model to get one level of the organisation tree
60 lines
1.6 KiB
PHP
60 lines
1.6 KiB
PHP
<?php
|
|
|
|
if (! defined("BASEPATH")) exit("No direct script access allowed");
|
|
|
|
class OrganisationseinheitLib
|
|
{
|
|
public function __construct()
|
|
{
|
|
$this->ci =& get_instance();
|
|
$this->ci->load->model('organisation/Organisationseinheit_model', 'OrganisationseinheitModel');
|
|
}
|
|
|
|
/**
|
|
* treeSearch
|
|
*
|
|
* This method searchs through the organisation tree starting from the bottom
|
|
* to the top, starting from the given oe_kurzbz. It stops when it finds a
|
|
* match with the other table, which attributes are passed as parameters:
|
|
* schema name, table name, fields to be selected, where conditions, orderby clause
|
|
*
|
|
* @param string $schema REQUIRED
|
|
* @param string $table REQUIRED
|
|
* @param mixed $fields REQUIRED
|
|
* @param string $where REQUIRED
|
|
* @param string $orderby REQUIRED
|
|
* @param string $oe_kurzbz REQUIRED
|
|
* @return array
|
|
*/
|
|
public function treeSearch($schema, $table, $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->getOneLevel($schema, $table, $select, $where, $orderby, $oe_kurzbz);
|
|
|
|
if (is_object($result) && $result->error == EXIT_SUCCESS && is_array($result->retval) && count($result->retval) > 0)
|
|
{
|
|
if ($result->retval[0]->_ppk != null && $result->retval[0]->oe_kurzbz == null)
|
|
{
|
|
return $this->treeSearch($schema, $table, $select, $where, $orderby, $result->retval[0]->_ppk);
|
|
}
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
} |