mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-02 12:49:27 +00:00
81e4f2968e
- Added new core controller called Auth_Controller that extends FHC_Controller and manage the authentication - All the controllers that were extending the CI_Controller now they extend the FHC_Controller - All the controllers that were extending the FHC_Controller now they extend the Auth_Controller - Added the method isAllowed to the FiltersLib to check if the authenticated user has the required permissions - FilterWidget and controller Filters are using the method isAllowed from the FiltersLib
116 lines
3.0 KiB
PHP
116 lines
3.0 KiB
PHP
<?php
|
|
/**
|
|
* PersonLog Extends from CI_Model instead of DB_Model
|
|
* to be able to write Log without a loggedin User!
|
|
*/
|
|
class PersonLog_model extends CI_Model
|
|
{
|
|
private $dbTable;
|
|
|
|
/**
|
|
* Constructor
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->database();
|
|
|
|
$this->dbTable = 'system.tbl_log';
|
|
}
|
|
|
|
/**
|
|
* Inserts a Log for a Person
|
|
* @param array $data Data of Log Entry to save.
|
|
* @return success object if true
|
|
*/
|
|
public function insert($data)
|
|
{
|
|
$result = $this->db->insert($this->dbTable, $data);
|
|
if ($result)
|
|
return success($this->db->insert_id());
|
|
else
|
|
return error();
|
|
}
|
|
|
|
/**
|
|
* Loads the last Log Entry of a Person
|
|
* @param int $person_id ID of the Person.
|
|
* @param string $taetigkeit_kurzbz Verarbeitungstätigkeit
|
|
* @param string $app Name of the App.
|
|
* @param string $oe_kurzbz Organisations Unit.
|
|
* @return object $result
|
|
*/
|
|
public function getLastLog($person_id, $taetigkeit_kurzbz = null, $app = null, $oe_kurzbz = null)
|
|
{
|
|
$this->db->order_by('zeitpunkt', 'DESC');
|
|
$this->db->order_by('log_id', 'DESC');
|
|
$this->db->limit(1);
|
|
if (!is_null($taetigkeit_kurzbz))
|
|
$this->db->where('taetigkeit_kurzbz='.$this->db->escape($oe_kurzbz));
|
|
if (!is_null($app))
|
|
$this->db->where('app='.$this->db->escape($app));
|
|
if (!is_null($oe_kurzbz))
|
|
$this->db->where('oe_kurzbz='.$this->db->escape($oe_kurzbz));
|
|
|
|
$result = $this->db->get_where($this->dbTable, "person_id=".$this->db->escape($person_id));
|
|
|
|
return success($result->result());
|
|
}
|
|
|
|
/**
|
|
* Load logs for a person, filtered by parameters
|
|
* @param int $person_id ID of the Person.
|
|
* @param string $taetigkeit_kurzbz Verarbeitungstätigkeit
|
|
* @param string $app Name of the App.
|
|
* @param string $oe_kurzbz Organisations Unit.
|
|
* @return object $result
|
|
*/
|
|
public function filterLog($person_id, $taetigkeit_kurzbz = null, $app = null, $oe_kurzbz = null)
|
|
{
|
|
$this->db->order_by('zeitpunkt', 'DESC');
|
|
$this->db->order_by('log_id', 'DESC');
|
|
if (!is_null($taetigkeit_kurzbz))
|
|
$this->db->where('taetigkeit_kurzbz='.$this->db->escape($taetigkeit_kurzbz));
|
|
if (!is_null($app))
|
|
$this->db->where('app='.$this->db->escape($app));
|
|
if (!is_null($oe_kurzbz))
|
|
$this->db->where('oe_kurzbz='.$this->db->escape($oe_kurzbz));
|
|
|
|
$result = $this->db->get_where($this->dbTable, "person_id=".$this->db->escape($person_id));
|
|
|
|
return success($result->result());
|
|
}
|
|
|
|
/**
|
|
* Gets all logs with zeitpunkt > today
|
|
* @param $person_id
|
|
* @return array
|
|
*/
|
|
public function getLogsInFuture($person_id)
|
|
{
|
|
$this->db->order_by('zeitpunkt', 'DESC');
|
|
$this->db->order_by('log_id', 'DESC');
|
|
|
|
$where = "logtype_kurzbz = 'Processstate'
|
|
AND person_id=".$this->db->escape($person_id)."
|
|
AND zeitpunkt >= now()";
|
|
|
|
$result = $this->db->get_where($this->dbTable, $where);
|
|
|
|
return success($result->result());
|
|
}
|
|
|
|
/**
|
|
* Deletes a log
|
|
* @param $log_id
|
|
* @return array
|
|
*/
|
|
public function deleteLog($log_id)
|
|
{
|
|
$this->db->where('log_id', $log_id);
|
|
$result = $this->db->delete($this->dbTable);
|
|
|
|
return success($result);
|
|
}
|
|
}
|