mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-19 07:52:16 +00:00
Messages: Bug-Report von STP: Berechtigung
Now the controller Redirect/redirectByToken doesn't use anymore the OrganisationseinheitLib, therefore authentication is not required anymore
This commit is contained in:
@@ -31,9 +31,6 @@ class Redirect extends FHC_Controller
|
||||
|
||||
// Loads model MessageTokenModel
|
||||
$this->load->model('system/MessageToken_model', 'MessageTokenModel');
|
||||
|
||||
// Loads library OrganisationseinheitLib
|
||||
$this->load->library('OrganisationseinheitLib');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,10 +52,23 @@ class Redirect extends FHC_Controller
|
||||
|
||||
if ($oe_kurzbz != null && $oe_kurzbz != '')
|
||||
{
|
||||
$rootOE = $this->organisationseinheitlib->getRoot($oe_kurzbz);
|
||||
if ($rootOE->error)
|
||||
$organisationRoot = null;
|
||||
$getOERoot = $this->MessageTokenModel->getOERoot($oe_kurzbz);
|
||||
if ($getOERoot) // If no errors occurred
|
||||
{
|
||||
show_error($rootOE->retval);
|
||||
// If data are present
|
||||
if (is_array($getOERoot->result()) && count($getOERoot->result()) > 0)
|
||||
{
|
||||
$organisationseinheit = $getOERoot->result()[0];
|
||||
if ($organisationseinheit->oe_kurzbz == null)
|
||||
{
|
||||
show_error('No organisation unit present in the message');
|
||||
}
|
||||
else
|
||||
{
|
||||
$organisationRoot = $organisationseinheit->oe_kurzbz;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$addonAufnahmeUrls = $this->config->item('addons_aufnahme_url');
|
||||
@@ -66,10 +76,10 @@ class Redirect extends FHC_Controller
|
||||
if (isset($token)
|
||||
&& hasData($msg)
|
||||
&& is_array($addonAufnahmeUrls)
|
||||
&& hasData($rootOE)
|
||||
&& isset($addonAufnahmeUrls[$rootOE->retval[0]->oe_kurzbz]))
|
||||
&& $organisationRoot != null
|
||||
&& isset($addonAufnahmeUrls[$organisationRoot]))
|
||||
{
|
||||
redirect($addonAufnahmeUrls[$rootOE->retval[0]->oe_kurzbz] . '?token=' . $token);
|
||||
redirect($addonAufnahmeUrls[$organisationRoot] . '?token=' . $token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class MessageToken_model extends CI_Model
|
||||
LIMIT 1';
|
||||
|
||||
$result = $this->db->query($sql, array(MSG_STATUS_DELETED, $token));
|
||||
|
||||
|
||||
// If no errors occurred
|
||||
if ($result)
|
||||
{
|
||||
@@ -58,7 +58,7 @@ class MessageToken_model extends CI_Model
|
||||
return error($this->db->error());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the status of a message to read. If the status of the message
|
||||
* is already read then update updateamum
|
||||
@@ -82,9 +82,9 @@ class MessageToken_model extends CI_Model
|
||||
) s ON (r.message_id = s.message_id AND r.person_id = s.person_id)
|
||||
WHERE r.token = ?
|
||||
LIMIT 1';
|
||||
|
||||
|
||||
$msgs = $this->db->query($sql, array(MSG_STATUS_ARCHIVED, $token));
|
||||
|
||||
|
||||
// If no errors occurred
|
||||
if ($msgs)
|
||||
{
|
||||
@@ -92,9 +92,9 @@ class MessageToken_model extends CI_Model
|
||||
if (count($msgs->result()) > 0)
|
||||
{
|
||||
$msg = $msgs->result()[0];
|
||||
|
||||
|
||||
$msgStatusResult = false; // pessimistic expectation
|
||||
|
||||
|
||||
// If the status of the message is unread
|
||||
if ($msg->status == MSG_STATUS_UNREAD)
|
||||
{
|
||||
@@ -118,31 +118,31 @@ class MessageToken_model extends CI_Model
|
||||
{
|
||||
// Update updateamum to current date
|
||||
$this->db->set('updateamum', 'NOW()');
|
||||
|
||||
|
||||
$this->db->where('message_id', $msg->message_id);
|
||||
$this->db->where('person_id', $msg->receiver_id);
|
||||
$this->db->where('status', MSG_STATUS_READ);
|
||||
|
||||
|
||||
$msgStatusResult = $this->db->update('public.tbl_msg_status');
|
||||
}
|
||||
|
||||
|
||||
// If some of the previous DB manipulation (update or insert) has failed
|
||||
if (!$msgStatusResult)
|
||||
{
|
||||
return error($this->db->error());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return success($msgs->result());
|
||||
}
|
||||
else
|
||||
{
|
||||
return error($this->db->error());
|
||||
}
|
||||
|
||||
|
||||
return success($result->result());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get data of the message sender
|
||||
*/
|
||||
@@ -159,9 +159,9 @@ class MessageToken_model extends CI_Model
|
||||
LEFT JOIN public.tbl_benutzer b USING(person_id)
|
||||
LEFT JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid)
|
||||
WHERE p.person_id = ?';
|
||||
|
||||
|
||||
$result = $this->db->query($sql, array($person_id));
|
||||
|
||||
|
||||
// If no errors occurred
|
||||
if ($result)
|
||||
{
|
||||
@@ -172,9 +172,9 @@ class MessageToken_model extends CI_Model
|
||||
return error($this->db->error());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public function isEmployee($person_id)
|
||||
{
|
||||
@@ -184,9 +184,9 @@ class MessageToken_model extends CI_Model
|
||||
LEFT JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid)
|
||||
WHERE p.person_id = ?
|
||||
AND b.aktiv = TRUE';
|
||||
|
||||
|
||||
$result = $this->db->query($sql, array($person_id));
|
||||
|
||||
|
||||
// If no errors occurred
|
||||
if ($result)
|
||||
{
|
||||
@@ -194,14 +194,14 @@ class MessageToken_model extends CI_Model
|
||||
if (is_array($result->result()) && count($result->result()) > 0)
|
||||
{
|
||||
$person = $result->result()[0];
|
||||
|
||||
|
||||
// If it is an employee
|
||||
if ($person->mitarbeiter_uid != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -209,4 +209,31 @@ class MessageToken_model extends CI_Model
|
||||
return error($this->db->error());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* getRoot - Get the root of the organisation unit tree which belongs the given organisation unit parameter
|
||||
*/
|
||||
public function getOERoot($oe_kurzbz)
|
||||
{
|
||||
$sql = 'SELECT oe_kurzbz, oe_parent_kurzbz FROM public.tbl_organisationseinheit WHERE oe_kurzbz = ?';
|
||||
|
||||
$result = $this->db->query($sql, array($oe_kurzbz));
|
||||
if ($result) // If no errors occurred
|
||||
{
|
||||
// If data are present
|
||||
if (is_array($result->result()) && count($result->result()) > 0)
|
||||
{
|
||||
$organisationseinheit = $result->result()[0];
|
||||
|
||||
// If this organisationseinheit has a parent
|
||||
if ($organisationseinheit->oe_parent_kurzbz != null)
|
||||
{
|
||||
// looks for the parent
|
||||
$result = $this->getOERoot($organisationseinheit->oe_parent_kurzbz);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user